generated from silverstripe/silverstripe-module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
executable file
·43 lines (36 loc) · 1.08 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
const Path = require('path');
const util = require('util');
const {
JavascriptWebpackConfig,
CssWebpackConfig,
} = require('@silverstripe/webpack-config');
const PATHS = {
ROOT: Path.resolve(),
SRC: Path.resolve('client/src'),
};
const cssWebpackConfig = new CssWebpackConfig('css', PATHS)
.setEntry({
bundle: `${PATHS.SRC}/styles/bundle.scss`,
})
.getConfig();
const jsWebpackConfig = new JavascriptWebpackConfig('js', PATHS)
.setEntry({
bundle: `${PATHS.SRC}/bundles/bundle.js`,
})
.getConfig()
// console.log(util.inspect(cssWebpackConfig, {showHidden: false, depth: null, colors: true}))
jsWebpackConfig.module.rules.push({
test: /\.css$/i,
use: ["style-loader", "css-loader"],
});
console.log(util.inspect(jsWebpackConfig, {showHidden: false, depth: null, colors: true}))
const config = [
// main JS bundle
jsWebpackConfig,
// sass to css
cssWebpackConfig
];
// 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;