-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
48 lines (43 loc) · 1.15 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
const path = require( 'path' );
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const defaultConfig = require('@wordpress/scripts/config/webpack.config');
delete defaultConfig.entry
delete defaultConfig.output
const isProduction = process.env.NODE_ENV === 'production';
let cssUse = [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'];
if (isProduction) {
cssUse = [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'sass-loader'];
}
module.exports = {
...defaultConfig,
entry: {
plugin: ['./src/js/plugin.js', './src/scss/editor.scss'],
},
output: {
filename: '[name].min.js',
path: path.resolve( process.cwd(), 'build' ),
},
module: {
...defaultConfig.module,
rules: [
...defaultConfig.module.rules,
{
test: /\.s?css$/,
use: cssUse
},
{
test: /\.svg$/,
use: ['@svgr/webpack'],
}
],
},
plugins: [
new MiniCssExtractPlugin({ filename: '[name].min.css' }),
! isProduction && new BrowserSyncPlugin({
files: '**/*.php',
injectChanges: true,
proxy: 'http://one.wordpress.test'
})
].filter( Boolean )
};