-
Notifications
You must be signed in to change notification settings - Fork 94
/
webpack.config.js
82 lines (80 loc) · 2.58 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
74
75
76
77
78
79
80
81
82
const webpack = require('webpack');
const { JavascriptWebpackConfig, CssWebpackConfig } = require('@silverstripe/webpack-config');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const PATHS = require('./webpack-vars');
const config = [
// Main JS bundles
new JavascriptWebpackConfig('js', PATHS, 'silverstripe/admin')
.setEntry({
vendor: `${PATHS.SRC}/bundles/vendor.js`,
bundle: `${PATHS.SRC}/bundles/bundle.js`,
'LeftAndMain.Ping': `${PATHS.LEGACY_SRC}/LeftAndMain.Ping.js`,
})
.splitVendor()
.mergeConfig({
plugins: [
new webpack.IgnorePlugin({ resourceRegExp: /^\.\/locale$/, contextRegExp: /moment$/ }),
new CopyWebpackPlugin({
patterns: [
{
from: `${PATHS.MODULES}/moment/locale`,
to: `${PATHS.DIST}/moment-locales`
},
{
from: `${PATHS.MODULES}/popper.js/dist/umd/popper.js`,
to: `${PATHS.THIRDPARTY}/popper/popper.min.js`
},
{
context: `${PATHS.SRC}/images`,
from: 'chosen-sprite*.png',
to: `${PATHS.DIST}/images/`
},
// Copy npm and custom tinymce content into the same dist directory
{
from: `${PATHS.MODULES}/tinymce`,
to: `${PATHS.DIST}/tinymce`
},
{
from: `${PATHS.SRC}/tinymce`,
to: `${PATHS.DIST}/tinymce`
},
]
}),
],
watchOptions: {
poll: true
}
})
.getConfig(),
// TinyMCE
new JavascriptWebpackConfig('tinymce', PATHS, 'silverstripe/admin')
.setEntry({
TinyMCE_sslink: `${PATHS.LEGACY_SRC}/TinyMCE_sslink.js`,
'TinyMCE_sslink-external': `${PATHS.LEGACY_SRC}/TinyMCE_sslink-external.js`,
'TinyMCE_sslink-email': `${PATHS.LEGACY_SRC}/TinyMCE_sslink-email.js`,
})
.mergeConfig({
watchOptions: {
poll: true
}
})
.getConfig(),
// i18n
new JavascriptWebpackConfig('i18n', PATHS, 'silverstripe/admin')
.setEntry({
i18n: `${PATHS.SRC}/i18n.js`
})
.getConfig(),
// sass to css
new CssWebpackConfig('css', PATHS)
.setEntry({
bundle: `${PATHS.SRC}/styles/bundle.scss`,
editor: `${PATHS.SRC}/styles/editor.scss`,
GridField_print: `${PATHS.SRC}/styles/legacy/GridField_print.scss`,
})
.getConfig(),
];
// 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)
: config;