2017-05-29 07:24:48 +02:00
|
|
|
const Path = require('path');
|
|
|
|
const webpackConfig = require('@silverstripe/webpack-config');
|
2020-12-21 22:25:15 +01:00
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
2017-05-29 07:24:48 +02:00
|
|
|
const {
|
|
|
|
resolveJS,
|
|
|
|
externalJS,
|
|
|
|
moduleJS,
|
|
|
|
pluginJS,
|
|
|
|
moduleCSS,
|
|
|
|
pluginCSS,
|
|
|
|
} = webpackConfig;
|
2016-08-21 03:18:54 +02:00
|
|
|
|
2017-05-29 07:24:48 +02:00
|
|
|
const ENV = process.env.NODE_ENV;
|
2016-08-21 03:18:54 +02:00
|
|
|
const PATHS = {
|
2017-05-29 07:24:48 +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/legacy'),
|
2016-08-21 03:18:54 +02:00
|
|
|
};
|
|
|
|
|
2017-05-29 07:24:48 +02:00
|
|
|
const config = [
|
2017-03-06 02:43:09 +01:00
|
|
|
{
|
2017-04-21 06:38:34 +02:00
|
|
|
name: 'js',
|
2017-03-06 02:43:09 +01:00
|
|
|
entry: {
|
2017-05-29 07:24:48 +02:00
|
|
|
bundle: `${PATHS.SRC}/bundles/bundle.js`,
|
2017-03-06 02:43:09 +01:00
|
|
|
// See https://github.com/webpack/webpack/issues/300#issuecomment-45313650
|
2017-05-29 07:24:48 +02:00
|
|
|
SilverStripeNavigator: `${PATHS.LEGACY_SRC}/SilverStripeNavigator.js`,
|
2017-05-25 07:29:32 +02:00
|
|
|
'TinyMCE_sslink-internal': `${PATHS.LEGACY_SRC}/TinyMCE_sslink-internal.js`,
|
2017-09-05 04:38:38 +02:00
|
|
|
'TinyMCE_sslink-anchor': `${PATHS.LEGACY_SRC}/TinyMCE_sslink-anchor.js`,
|
2017-03-06 02:43:09 +01:00
|
|
|
},
|
|
|
|
output: {
|
2017-05-29 07:24:48 +02:00
|
|
|
path: PATHS.DIST,
|
2017-03-06 02:43:09 +01:00
|
|
|
filename: 'js/[name].js',
|
|
|
|
},
|
2017-05-29 07:24:48 +02:00
|
|
|
devtool: (ENV !== 'production') ? 'source-map' : '',
|
|
|
|
resolve: resolveJS(ENV, PATHS),
|
2017-05-30 02:32:18 +02:00
|
|
|
externals: externalJS(ENV, PATHS),
|
2017-05-29 07:24:48 +02:00
|
|
|
module: moduleJS(ENV, PATHS),
|
2020-12-21 22:25:15 +01:00
|
|
|
plugins: pluginJS(ENV, PATHS).concat([
|
|
|
|
new CopyWebpackPlugin([
|
|
|
|
{ from: 'client/src/images', to: 'images' },
|
|
|
|
])
|
|
|
|
])
|
2016-08-21 03:18:54 +02:00
|
|
|
},
|
2017-03-06 02:43:09 +01:00
|
|
|
{
|
|
|
|
name: 'css',
|
|
|
|
entry: {
|
2017-05-29 07:24:48 +02:00
|
|
|
bundle: `${PATHS.SRC}/styles/bundle.scss`,
|
|
|
|
SilverStripeNavigator: `${PATHS.SRC}/styles/SilverStripeNavigator.scss`,
|
2017-03-06 02:43:09 +01:00
|
|
|
},
|
|
|
|
output: {
|
2017-05-29 07:24:48 +02:00
|
|
|
path: PATHS.DIST,
|
|
|
|
filename: 'styles/[name].css',
|
2017-03-06 02:43:09 +01:00
|
|
|
},
|
2017-05-29 07:24:48 +02:00
|
|
|
devtool: (ENV !== 'production') ? 'source-map' : '',
|
|
|
|
module: moduleCSS(ENV, PATHS),
|
|
|
|
plugins: pluginCSS(ENV, PATHS),
|
2017-03-06 02:43:09 +01:00
|
|
|
},
|
|
|
|
];
|
2017-05-29 07:24:48 +02:00
|
|
|
|
|
|
|
// 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;
|