-
Notifications
You must be signed in to change notification settings - Fork 225
/
webpack.config.js
73 lines (68 loc) · 1.9 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const Path = require('path');
const { JavascriptWebpackConfig, CssWebpackConfig } = require('@silverstripe/webpack-config');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ENV = process.env.NODE_ENV;
const PATHS = {
MODULES: 'node_modules',
ROOT: Path.resolve(),
SRC: Path.resolve('client/src'),
DIST: Path.resolve('client/dist'),
};
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();
// Don't apply any externals, as this js will be used on the front-end.
frontendJsConfig.externals = {};
const config = [
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({
userforms: `${PATHS.SRC}/styles/bundle.scss`,
'userforms-cms': `${PATHS.SRC}/styles/bundle-cms.scss`,
})
.getConfig(),
];
module.exports = config;