From: Tim Düsterhus Date: Fri, 10 Jul 2015 22:27:41 +0000 (+0200) Subject: Use different build config for JavaScript in frontend and ACP X-Git-Tag: 3.0.0_Beta_1~2188 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6f833b1dfea7b132b343fc61bb6258dd5ec1aafe;p=GitHub%2FWoltLab%2FWCF.git Use different build config for JavaScript in frontend and ACP Frontend JavaScript will skip the WoltLab/WCF/Acp tree and ACP JavaScript excludes WoltLab/WCF/Bootstrap + dependencies. --- diff --git a/wcfsetup/install/files/js/require.build-acp.js b/wcfsetup/install/files/js/require.build-acp.js new file mode 100644 index 0000000000..ae2aca4184 --- /dev/null +++ b/wcfsetup/install/files/js/require.build-acp.js @@ -0,0 +1,51 @@ +({ + mainConfigFile: 'require.config.js', + name: "WoltLab/_Meta", + out: "WCF.ACP.min.js", + useStrict: true, + preserveLicenseComments: false, + optimize: 'uglify2', + uglify2: {}, + excludeShallow: [ + 'WoltLab/_Meta' + ], + exclude: [ + 'WoltLab/WCF/Bootstrap' + ], + rawText: { + 'WoltLab/_Meta': 'define([], function() {});' + }, + onBuildRead: function(moduleName, path, contents) { + if (!process.versions.node) { + throw new Error('You need to run node.js'); + } + + if (moduleName === 'WoltLab/_Meta') { + if (global.allModules == undefined) { + var fs = module.require('fs'), + path = module.require('path'); + global.allModules = []; + + var queue = ['WoltLab/WCF/Acp']; + var folder; + while (folder = queue.shift()) { + var files = fs.readdirSync(folder); + for (var i = 0; i < files.length; i++) { + var filename = path.join(folder, files[i]); + + if (path.extname(filename) == '.js') { + global.allModules.push(filename); + } + else if (fs.statSync(filename).isDirectory()) { + queue.push(filename); + } + } + } + } + + return 'define([' + global.allModules.map(function (item) { return "'" + item.replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/\.js$/, '') + "'"; }).join(', ') + '], function() { });'; + } + + return contents; + } +}) diff --git a/wcfsetup/install/files/js/require.build.js b/wcfsetup/install/files/js/require.build.js index 12255c132a..1bbb02e169 100644 --- a/wcfsetup/install/files/js/require.build.js +++ b/wcfsetup/install/files/js/require.build.js @@ -39,7 +39,8 @@ var files = fs.readdirSync(folder); for (var i = 0; i < files.length; i++) { var filename = path.join(folder, files[i]); - + if (filename === 'WoltLab/WCF/Acp') continue; + if (path.extname(filename) == '.js') { global.allModules.push(filename); }