-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
48 lines (42 loc) · 1.12 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
/* eslint-disable */
const defaultConfig = require('@wordpress/scripts/config/webpack.config');
// Import the helper to find and generate the entry points in the src directory
const { getWebpackEntryPoints } = require( '@wordpress/scripts/utils/config' );
// Check if it's a production build
const isProduction = process.env.NODE_ENV === 'production';
let optimization = defaultConfig.optimization;
if (isProduction) {
optimization = {
...defaultConfig.optimization,
};
}
// Set the devtool based on the build environment
const devtool = isProduction ? false : 'eval-source-map';
module.exports = {
...defaultConfig,
entry: {
...getWebpackEntryPoints('script')(),
},
devtool: devtool,
module: {
...defaultConfig.module,
rules: [
...defaultConfig.module.rules,
// TypeScript loader
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
...defaultConfig.resolve,
extensions: ['.tsx', '.ts', '.js', '.json'],
},
optimization: optimization,
performance: {
...defaultConfig.performance,
hints: false
},
};