-
Notifications
You must be signed in to change notification settings - Fork 120
Expand file tree
/
Copy pathwebpack.config.js
More file actions
43 lines (41 loc) · 1.35 KB
/
webpack.config.js
File metadata and controls
43 lines (41 loc) · 1.35 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
37
38
39
40
41
42
43
const defaultConfig = require('@wordpress/scripts/config/webpack.config');
const path = require('path');
// Resolve webpack from wp-scripts' dependencies (same version, no mismatch)
const wpScriptsDir = path.dirname(require.resolve('@wordpress/scripts/config/webpack.config'));
const webpack = require(require.resolve('webpack', { paths: [wpScriptsDir] }));
module.exports = {
...defaultConfig,
entry: {
pm: './views/assets/src/index.jsx',
},
output: {
path: path.resolve(__dirname, 'views/assets/dist'),
filename: '[name].js',
publicPath: 'auto',
clean: true,
},
resolve: {
...defaultConfig.resolve,
alias: {
...(defaultConfig.resolve?.alias || {}),
'@': path.resolve(__dirname, 'views/assets/src'),
'@components': path.resolve(__dirname, 'views/assets/src/components'),
'@store': path.resolve(__dirname, 'views/assets/src/store'),
'@hooks': path.resolve(__dirname, 'views/assets/src/hooks'),
'@lib': path.resolve(__dirname, 'views/assets/src/lib'),
},
extensions: ['.jsx', '.js', '.json'],
},
optimization: {
...defaultConfig.optimization,
splitChunks: false,
runtimeChunk: false,
},
plugins: [
...(defaultConfig.plugins || []),
new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
],
externals: {
jquery: 'jQuery',
},
};