-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathwebpack.config.js
More file actions
32 lines (28 loc) · 999 Bytes
/
Copy pathwebpack.config.js
File metadata and controls
32 lines (28 loc) · 999 Bytes
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
const defaultConfig = require('10up-toolkit/config/webpack.config');
const KNOWN_SHARED_UI_ASSETS = /^(css\/admin-style\.css|fonts\/wpmudev-plugin-icons\.svg)$/;
const SHARED_UI_ENTRYPOINT_BUDGET = 700 * 1024;
/**
* Apply project-specific build budgets while keeping the 10up defaults.
*
* @param {object} config The default 10up Toolkit webpack configuration.
*
* @returns {object} The project webpack configuration.
*/
const configureWebpack = (config) => {
const defaultAssetFilter =
config.performance && typeof config.performance.assetFilter === 'function'
? config.performance.assetFilter
: () => true;
return {
...config,
performance: {
...config.performance,
maxEntrypointSize: SHARED_UI_ENTRYPOINT_BUDGET,
assetFilter: (assetFilename) =>
!KNOWN_SHARED_UI_ASSETS.test(assetFilename) && defaultAssetFilter(assetFilename),
},
};
};
module.exports = Array.isArray(defaultConfig)
? defaultConfig.map(configureWebpack)
: configureWebpack(defaultConfig);