Use different build config for JavaScript in frontend and ACP
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 10 Jul 2015 22:27:41 +0000 (00:27 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 10 Jul 2015 22:27:41 +0000 (00:27 +0200)
Frontend JavaScript will skip the WoltLab/WCF/Acp tree and ACP
JavaScript excludes WoltLab/WCF/Bootstrap + dependencies.

wcfsetup/install/files/js/require.build-acp.js [new file with mode: 0644]
wcfsetup/install/files/js/require.build.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 (file)
index 0000000..ae2aca4
--- /dev/null
@@ -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;
+       }
+})
index 12255c132a02591e5153edf7c6bb79f4436b0e18..1bbb02e16984eb24888f44cdaa2d9c219a414f52 100644 (file)
@@ -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);
                                                }