From 6f833b1dfea7b132b343fc61bb6258dd5ec1aafe Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 11 Jul 2015 00:27:41 +0200 Subject: [PATCH] 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. --- .../install/files/js/require.build-acp.js | 51 +++++++++++++++++++ wcfsetup/install/files/js/require.build.js | 3 +- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 wcfsetup/install/files/js/require.build-acp.js 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); } -- 2.20.1