Add support for CommonsChunkPlugin for Webpack.

This lets us consolidate chunks of JavaScript that are common to
multiple bundles, so that they can live in their own shared file. This
will be more relevant when we have UI components -- there's actually
very little shared code right now.
This commit is contained in:
David Ormsbee
2017-06-21 21:46:59 -04:00
parent 1ad2b66e14
commit 962b09f73c
3 changed files with 28 additions and 0 deletions

View File

@@ -44,6 +44,18 @@ var webpackConfig = require(path.join(appRoot, 'webpack.config.js'));
delete webpackConfig.entry;
// The following crazy bit is to work around the webpack.optimize.CommonsChunkPlugin
// plugin. The problem is that it it factors out the code that defines webpackJsonp
// and puts in in the commons JS, which Karma doesn't know to load first. This is a
// workaround recommended in the karma-webpack bug report that basically just removes
// the plugin for the purposes of Karma testing (the plugin is meant to be an
// optimization only).
// https://github.com/webpack-contrib/karma-webpack/issues/24#issuecomment-257613167
//
// This should be fixed in v3 of karma-webpack
const commonsChunkPluginIndex = webpackConfig.plugins.findIndex(plugin => plugin.chunkNames);
webpackConfig.plugins.splice(commonsChunkPluginIndex, 1);
// Files which are needed by all lms/cms suites.
var commonFiles = {
libraryFiles: [