-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
46 lines (43 loc) · 958 Bytes
/
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
const path = require( 'path' );
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
const fastGlob = require( 'fast-glob' );
const WebpackBar = require( 'webpackbar' );
const ReplaceInFileWebpackPlugin = require( 'replace-in-file-webpack-plugin' );
const sharedConfig = {
...defaultConfig,
plugins: [
...defaultConfig.plugins,
new ReplaceInFileWebpackPlugin( [
{
dir: 'dist',
test: [ /\.js/ ],
rules: [
{
search: /TEXTDOMAIN/gi,
replace: 'wp-plugin-scaffold',
},
],
},
] ),
],
};
const scripts = {
...sharedConfig,
entry: {
'app': './assets/scripts/src/index.js',
'admin': './assets/scripts/src/admin.js',
},
output: {
path: path.resolve( process.cwd(), 'dist' ),
filename: '[name].js',
chunkFilename: '[name].js',
},
plugins: [
...sharedConfig.plugins,
new WebpackBar( {
name: 'Scripts',
color: '#5aec1c',
} ),
],
};
module.exports = [ scripts ];