-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
83 lines (80 loc) · 2.08 KB
/
Copy pathwebpack.config.js
File metadata and controls
83 lines (80 loc) · 2.08 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
const path = require('path');
const defaultConfig = require('@wordpress/scripts/config/webpack.config');
const DependencyExtractionWebpackPlugin = require('@wordpress/dependency-extraction-webpack-plugin');
const wpIconsRequest = '@wordpress/icons';
const defaultEntry = defaultConfig.entry;
module.exports = {
...defaultConfig,
// Extend the default entry map to include the optional BAC validation script.
entry: async () => {
const base =
typeof defaultEntry === 'function'
? await defaultEntry()
: defaultEntry;
return {
...base,
validation: path.resolve(__dirname, 'src/validation.js'),
view: path.resolve(__dirname, 'src/view.js'),
};
},
resolve: {
...(defaultConfig.resolve || {}),
alias: {
...(defaultConfig.resolve?.alias || {}),
'react/jsx-runtime$': path.resolve(
__dirname,
'node_modules/react/jsx-runtime.js'
),
'react/jsx-dev-runtime$': path.resolve(
__dirname,
'node_modules/react/jsx-dev-runtime.js'
),
},
},
plugins: [
...(defaultConfig.plugins || []).filter(
(plugin) =>
plugin.constructor.name !== 'DependencyExtractionWebpackPlugin'
),
new DependencyExtractionWebpackPlugin({
requestToExternal(request) {
if (request === wpIconsRequest) {
return null;
}
},
}),
],
output: {
...defaultConfig.output,
chunkFilename: '[name].js',
},
optimization: {
...defaultConfig.optimization,
splitChunks: {
...defaultConfig.optimization.splitChunks,
chunks: 'async',
maxSize: 240000,
cacheGroups: {
...defaultConfig.optimization.splitChunks.cacheGroups,
citationBibtex: {
test: /[\\/]node_modules[\\/]@citation-js[\\/]plugin-bibtex[\\/]/,
name: 'citation-plugin-bibtex',
chunks: 'async',
enforce: true,
},
citationDoi: {
test: /[\\/]node_modules[\\/]@citation-js[\\/]plugin-doi[\\/]/,
name: 'citation-plugin-doi',
chunks: 'async',
enforce: true,
},
citationCore: {
test: /[\\/]node_modules[\\/]@citation-js[\\/](core|date|name)[\\/]/,
name: 'citation-core',
chunks: 'async',
enforce: true,
},
},
},
},
};