2017-08-16 05:20:15 +02:00
|
|
|
const Path = require('path');
|
2023-01-30 23:20:28 +01:00
|
|
|
const { JavascriptWebpackConfig, CssWebpackConfig } = require('@silverstripe/webpack-config');
|
2020-12-08 02:56:47 +01:00
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
2017-08-16 05:20:15 +02:00
|
|
|
|
|
|
|
const ENV = process.env.NODE_ENV;
|
|
|
|
const PATHS = {
|
|
|
|
MODULES: 'node_modules',
|
|
|
|
ROOT: Path.resolve(),
|
|
|
|
SRC: Path.resolve('client/src'),
|
|
|
|
DIST: Path.resolve('client/dist'),
|
|
|
|
};
|
|
|
|
|
2023-01-30 23:20:28 +01:00
|
|
|
const frontendJsConfig = new JavascriptWebpackConfig('js-frontend', PATHS, 'silverstripe/userforms')
|
|
|
|
.setEntry({
|
|
|
|
userforms: `${PATHS.SRC}/bundles/bundle.js`,
|
|
|
|
})
|
|
|
|
.mergeConfig({
|
|
|
|
plugins: [
|
|
|
|
new CopyWebpackPlugin({
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: `${PATHS.MODULES}/jquery/dist/jquery.min.js`,
|
|
|
|
to: `${PATHS.DIST}/js`
|
|
|
|
},
|
|
|
|
{
|
|
|
|
from: `${PATHS.MODULES}/jquery.are-you-sure/jquery.are-you-sure.js`,
|
|
|
|
to: `${PATHS.DIST}/js/jquery.are-you-sure/`
|
|
|
|
},
|
|
|
|
{
|
|
|
|
context: `${PATHS.MODULES}/jquery-validation/dist`,
|
|
|
|
from: '**/*.min.js',
|
|
|
|
to: `${PATHS.DIST}/js/jquery-validation/`
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
})
|
|
|
|
.getConfig();
|
2021-03-04 05:05:55 +01:00
|
|
|
|
2023-01-30 23:20:28 +01:00
|
|
|
// Don't apply any externals, as this js will be used on the front-end.
|
|
|
|
frontendJsConfig.externals = {};
|
2021-03-04 05:05:55 +01:00
|
|
|
|
2017-08-16 05:20:15 +02:00
|
|
|
const config = [
|
2023-01-30 23:20:28 +01:00
|
|
|
frontendJsConfig,
|
|
|
|
// Main JS bundle
|
|
|
|
new JavascriptWebpackConfig('js-cms', PATHS, 'silverstripe/userforms')
|
|
|
|
.setEntry({
|
|
|
|
'userforms-cms': `${PATHS.SRC}/bundles/bundle-cms.js`,
|
|
|
|
})
|
|
|
|
.mergeConfig({
|
|
|
|
plugins: [
|
|
|
|
new CopyWebpackPlugin({
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
context: `${PATHS.SRC}/images`,
|
|
|
|
from: '**/*.png',
|
|
|
|
to: `${PATHS.DIST}/images`
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
})
|
|
|
|
.getConfig(),
|
|
|
|
// sass to css
|
|
|
|
new CssWebpackConfig('css', PATHS)
|
|
|
|
.setEntry({
|
2017-08-21 02:13:19 +02:00
|
|
|
userforms: `${PATHS.SRC}/styles/bundle.scss`,
|
|
|
|
'userforms-cms': `${PATHS.SRC}/styles/bundle-cms.scss`,
|
2023-01-30 23:20:28 +01:00
|
|
|
})
|
|
|
|
.getConfig(),
|
2017-08-16 05:20:15 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
module.exports = config;
|