-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
64 lines (58 loc) · 1.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
// WordPress webpack config.
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
// Plugins.
const WebpackWatchedGlobEntries = require('webpack-watched-glob-entries-plugin');
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
const RemoveEmptyScriptsPlugin = require( 'webpack-remove-empty-scripts' );
// Utilities.
const path = require( 'path' );
// package.json sets the default source to ./src and output to ./assets/css
// so entry and output below should be relative to those.
module.exports = {
...defaultConfig,
...{
entry: WebpackWatchedGlobEntries.getEntries(
[
path.resolve(__dirname, 'src/scss/**/*.scss'),
],
{
ignore: '**/_*.scss'
}
),
module: {
rules: [
{
test: /\.(sa|sc|c)ss$/,
use: [
{ loader: MiniCssExtractPlugin.loader },
{ loader: 'css-loader' },
{ loader: 'sass-loader',
options: {
// turn off minification
sassOptions: {
outputStyle: 'expanded',
},
},
},
],
},
],
},
plugins: [
// Include WP's plugin config.
...defaultConfig.plugins,
// Load multiple entry points plugin
new WebpackWatchedGlobEntries(),
// Load minimize CSS plugin so we can turn off minimizing above
// with outputStyle: 'expanded'
new MiniCssExtractPlugin(),
// Removes the empty `.js` files generated by webpack but
new RemoveEmptyScriptsPlugin( {
stage: RemoveEmptyScriptsPlugin.STAGE_AFTER_PROCESS_PLUGINS,
} ),
],
// turn off source maps
mode: 'development',
devtool: false,
},
};