UNPKG

cloudcms-webpack-plugin

Version:

Provides facilities for building Cloud CMS UI modules using webpack

70 lines (56 loc) 1.6 kB
// certain modules are provided by the Cloud CMS UI and so should not be packaged // we use this function to filter those out var externalFn = function(context, request, callback) { var CORE_MODULES = [ /^ratchet/, /^oneteam/, /^app/, /^accounting/, /^jquery/, /^moment/, /^alpaca/, /^bootstrap/, /^jquery/, /^handlebars/, /^content-helpers/, /^ui/, /^gitana/, /^vendor/, /^ckeditor/, /^jstree/ ]; for (var i = 0; i < CORE_MODULES.length; i++) { if (CORE_MODULES[i].test(request)) { return callback(null, 'amd ' + request); } } callback(); }; function Plugin(options) { options = options || {}; } Plugin.prototype.constructor = Plugin; Plugin.prototype.apply = function(compiler) { compiler.hooks.emit.tapAsync("Cloud CMS Plugin", function(compilation, callback) { // loop through all of the files and write a build.json file var build = { "files": [] }; for (var filename in compilation.assets) { build.files.push(filename); } // Insert this list into the Webpack build as a new file asset: compilation.assets['build.json'] = { source: function() { return JSON.stringify(build, null, 2); }, size: function() { return build.files.length; } }; callback(); }); }; Plugin.externalFn = externalFn; module.exports = Plugin;