silverstripe-frameworktest/webpack.config.js
2017-11-06 16:56:59 +13:00

43 lines
1.0 KiB
JavaScript

const Path = require('path');
const webpackConfig = require('@silverstripe/webpack-config');
const {
resolveJS,
externalJS,
moduleJS,
pluginJS,
} = webpackConfig;
const ENV = process.env.NODE_ENV;
const PATHS = {
MODULES: 'node_modules',
FILES_PATH: '../',
ROOT: Path.resolve(),
SRC: Path.resolve('client/src'),
DIST: Path.resolve('client/dist'),
LEGACY_SRC: Path.resolve('client/src'),
};
const config = [
{
name: 'js',
entry: {
legacy: `${PATHS.LEGACY_SRC}/bundles/legacy.js`,
},
output: {
path: PATHS.DIST,
filename: 'js/[name].js',
},
devtool: (ENV !== 'production') ? 'source-map' : '',
resolve: resolveJS(ENV, PATHS),
externals: externalJS(ENV, PATHS),
module: moduleJS(ENV, PATHS),
plugins: pluginJS(ENV, PATHS),
},
];
// Use WEBPACK_CHILD=js or WEBPACK_CHILD=css env var to run a single config
module.exports = (process.env.WEBPACK_CHILD)
? config.find(entry => entry.name === process.env.WEBPACK_CHILD)
: module.exports = config;