-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
37 lines (30 loc) · 944 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
const webpack = require( 'webpack' ),
path = require( 'path' ),
glob = require( 'glob' ),
RemoveEmptyScriptsPlugin = require( 'webpack-remove-empty-scripts' ),
defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
module.exports = {
...defaultConfig,
entry: glob.sync( './src/**/*.{js,ts,scss}' ).reduce( ( acc, path ) => {
const entry = path.replace( /^\.\/src\//i, '' ).replace( /\.(js|ts|scss)/i, '' );
acc[ entry ] = path;
return acc;
}, {} ),
output: {
filename: '[name].js',
path: path.resolve( process.cwd(), 'dist/' ),
},
optimization: {
...defaultConfig.optimization,
concatenateModules: true,
minimize: true,
},
devtool: 'source-map',
resolve: {
fallback: { 'url': require.resolve( 'url/' ) }
},
plugins: [
...defaultConfig.plugins,
new RemoveEmptyScriptsPlugin()
],
}