This repository has been archived by the owner on Jul 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
77 lines (71 loc) · 2.02 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
/*
* This configuration is based on the npm module @silverstripe/webpack-config:
* https://www.npmjs.com/org/silverstripe
*/
const path = require('path');
const webpack = require('webpack');
// Import the SilverStripe core config
const webpackConfig = require('@silverstripe/webpack-config');
const {
resolveJS,
externalJS,
moduleJS,
pluginJS,
moduleCSS,
pluginCSS,
} = webpackConfig;
const ENV = process.env.NODE_ENV;
const PATHS = {
MODULE: {
ROOT: path.resolve(),
MODULES: 'node_modules',
SRC: path.resolve('client/src'),
DIST: path.resolve('client/dist'),
BUNDLES: path.resolve('client/src/bundles'),
STYLES: path.resolve('client/src/styles'),
},
ADMIN: {
ROOT: path.resolve(),
MODULES: 'node_modules',
SRC: path.resolve('admin/client/src'),
DIST: path.resolve('admin/client/dist'),
BUNDLES: path.resolve('admin/client/src/bundles'),
STYLES: path.resolve('admin/client/src/styles'),
}
};
const config = [
{
entry: {
bundle: PATHS.ADMIN.BUNDLES + '/bundle.js'
},
output: {
path: PATHS.ADMIN.DIST,
filename: 'bundle.js',
sourceMapFilename: 'bundle.js.map'
},
devtool: (ENV !== 'production') ? 'source-map' : '',
resolve: resolveJS(ENV, PATHS.ADMIN),
externals: externalJS(ENV, PATHS.ADMIN),
module: moduleJS(ENV, PATHS.ADMIN),
plugins: pluginJS(ENV, PATHS.ADMIN),
},
{
entry: {
bundle: PATHS.ADMIN.STYLES + '/bundle.scss'
},
output: {
path: PATHS.ADMIN.DIST,
filename: 'css.js',
sourceMapFilename: 'bundle.css.map'
},
devtool: (ENV !== 'production') ? 'source-map' : '',
module: moduleCSS(ENV, PATHS.ADMIN),
plugins: pluginCSS(ENV, PATHS.ADMIN),
},
];
module.exports = (env = {development: true}) => {
process.env.NODE_ENV = (env.production ? 'production' : 'development');
console.log(`Running in ${process.env.NODE_ENV} mode...`);
return config(process.env.NODE_ENV);
};
module.exports = config;