forked from maxime-rainville/silverstripe-link
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
66 lines (63 loc) · 1.74 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
const Path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const webpackConfig = require('@silverstripe/webpack-config');
const {
resolveJS,
externalJS,
moduleJS,
pluginJS,
moduleCSS,
pluginCSS,
} = webpackConfig;
const ENV = process.env.NODE_ENV;
const PATHS = {
MODULES: 'node_modules',
FILES_PATH: '../',
ROOT: Path.resolve(),
SRC: Path.resolve('client/src'),
DIST: Path.resolve('client/dist'),
LEGACY_SRC: Path.resolve('client/src/entwine'),
};
const config = [
{
name: 'js',
entry: {
bundle: `${PATHS.SRC}/bundles/bundle.js`
},
output: {
path: PATHS.DIST,
filename: 'js/[name].js',
},
devtool: (ENV !== 'production') ? 'source-map' : '',
resolve: resolveJS(ENV, PATHS),
externals: Object.assign(
{},
externalJS(ENV, PATHS),
{
// @todo remove this once @silverstripe/webpack-config has this updated and published
'containers/InsertLinkModal/fileSchemaModalHandler': 'FileSchemaModalHandler',
'state/unsavedForms/UnsavedFormsActions': 'UnsavedFormsActions',
'components/ActionMenu/ActionMenu': 'ActionMenu',
}
),
module: moduleJS(ENV, PATHS),
plugins: pluginJS(ENV, PATHS),
},
{
name: 'css',
entry: {
bundle: `${PATHS.SRC}/styles/bundle.scss`,
},
output: {
path: PATHS.DIST,
filename: 'styles/[name].css',
},
devtool: (ENV !== 'production') ? 'source-map' : '',
module: moduleCSS(ENV, PATHS),
plugins: pluginCSS(ENV, PATHS),
}
];
// 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;