2017-05-29 07:24:48 +02:00
|
|
|
const Path = require('path');
|
2022-12-18 22:20:52 +01:00
|
|
|
const { JavascriptWebpackConfig, CssWebpackConfig } = require('@silverstripe/webpack-config');
|
2020-12-21 22:25:15 +01:00
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
2016-08-21 03:18:54 +02:00
|
|
|
|
|
|
|
const PATHS = {
|
2017-05-29 07:24:48 +02:00
|
|
|
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 = [
|
2022-12-18 22:20:52 +01:00
|
|
|
// Main JS bundles
|
|
|
|
new JavascriptWebpackConfig('js', PATHS, 'silverstripe/cms')
|
|
|
|
.setEntry({
|
2017-05-29 07:24:48 +02:00
|
|
|
bundle: `${PATHS.SRC}/bundles/bundle.js`,
|
|
|
|
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`,
|
2022-12-18 22:20:52 +01:00
|
|
|
})
|
|
|
|
.mergeConfig({
|
|
|
|
plugins: [
|
|
|
|
new CopyWebpackPlugin({
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: `${PATHS.SRC}/images`,
|
|
|
|
to: `${PATHS.DIST}/images`
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
})
|
|
|
|
.getConfig(),
|
|
|
|
// sass to css
|
|
|
|
new CssWebpackConfig('css', PATHS)
|
|
|
|
.setEntry({
|
2017-05-29 07:24:48 +02:00
|
|
|
bundle: `${PATHS.SRC}/styles/bundle.scss`,
|
|
|
|
SilverStripeNavigator: `${PATHS.SRC}/styles/SilverStripeNavigator.scss`,
|
2022-12-18 22:20:52 +01:00
|
|
|
})
|
|
|
|
.getConfig(),
|
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)
|
2022-12-18 22:20:52 +01:00
|
|
|
: config;
|