2017-08-16 05:37:11 +02:00
|
|
|
const Path = require('path');
|
|
|
|
const webpackConfig = require('@silverstripe/webpack-config');
|
2017-11-06 04:56:59 +01:00
|
|
|
|
2017-08-16 05:37:11 +02:00
|
|
|
const {
|
|
|
|
resolveJS,
|
|
|
|
externalJS,
|
|
|
|
moduleJS,
|
|
|
|
pluginJS,
|
|
|
|
} = webpackConfig;
|
2016-09-29 02:39:07 +02:00
|
|
|
|
2017-08-16 05:37:11 +02:00
|
|
|
const ENV = process.env.NODE_ENV;
|
2016-09-29 02:39:07 +02:00
|
|
|
const PATHS = {
|
2017-08-16 05:37:11 +02:00
|
|
|
MODULES: 'node_modules',
|
|
|
|
FILES_PATH: '../',
|
|
|
|
ROOT: Path.resolve(),
|
|
|
|
SRC: Path.resolve('client/src'),
|
|
|
|
DIST: Path.resolve('client/dist'),
|
|
|
|
LEGACY_SRC: Path.resolve('client/src'),
|
2016-09-29 02:39:07 +02:00
|
|
|
};
|
|
|
|
|
2017-08-16 05:37:11 +02:00
|
|
|
const config = [
|
|
|
|
{
|
2016-09-29 02:39:07 +02:00
|
|
|
name: 'js',
|
|
|
|
entry: {
|
2017-08-16 05:37:11 +02:00
|
|
|
legacy: `${PATHS.LEGACY_SRC}/bundles/legacy.js`,
|
2016-09-29 02:39:07 +02:00
|
|
|
},
|
|
|
|
output: {
|
2017-08-16 05:37:11 +02:00
|
|
|
path: PATHS.DIST,
|
|
|
|
filename: 'js/[name].js',
|
2016-09-29 02:39:07 +02:00
|
|
|
},
|
2017-08-16 05:37:11 +02:00
|
|
|
devtool: (ENV !== 'production') ? 'source-map' : '',
|
|
|
|
resolve: resolveJS(ENV, PATHS),
|
|
|
|
externals: externalJS(ENV, PATHS),
|
|
|
|
module: moduleJS(ENV, PATHS),
|
|
|
|
plugins: pluginJS(ENV, PATHS),
|
|
|
|
},
|
|
|
|
];
|
2016-09-29 02:39:07 +02:00
|
|
|
|
|
|
|
// Use WEBPACK_CHILD=js or WEBPACK_CHILD=css env var to run a single config
|
2017-08-16 05:37:11 +02:00
|
|
|
module.exports = (process.env.WEBPACK_CHILD)
|
2017-11-06 04:56:59 +01:00
|
|
|
? config.find(entry => entry.name === process.env.WEBPACK_CHILD)
|
2017-08-16 05:37:11 +02:00
|
|
|
: module.exports = config;
|