-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
36 lines (34 loc) · 1.31 KB
/
webpack.config.js
File metadata and controls
36 lines (34 loc) · 1.31 KB
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
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
const path = require( 'path' );
const isProduction = process.env.NODE_ENV === 'production';
const buildMode = process.env.BUILD_MODE || ( isProduction ? 'prod' : 'dev' );
const outputPath = path.resolve(
process.cwd(),
buildMode === 'prod' ? 'build' : 'build-dev'
);
module.exports = {
...defaultConfig,
entry: {
index: path.resolve( process.cwd(), 'resources', 'js', 'index.tsx' ),
},
output: {
path: outputPath,
filename: '[name].js',
chunkFilename: '[name].js?ver=[contenthash]',
},
resolve: {
...defaultConfig.resolve,
alias: {
'@': path.resolve( process.cwd(), 'resources', 'js' ),
'@components': path.resolve( process.cwd(), 'resources', 'js', 'components' ),
'@lib': path.resolve( process.cwd(), 'resources', 'js', 'lib' ),
'@css': path.resolve( process.cwd(), 'resources', 'css' ),
'@img': path.resolve( process.cwd(), 'resources', 'img' ),
},
},
optimization: {
...defaultConfig.optimization,
...( buildMode === 'prod' && { minimize: true, usedExports: true } ),
},
devtool: buildMode === 'prod' ? false : 'source-map',
};