mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 02:59:58 +08:00
test: add @bundle-analyzer/webpack-plugin (#24399)
* add @bundle-analyzer/webpack-plugin * add .bundle-analyzerrc * use process.env.BUNDLE_ANALYZER_TOKEN * more dist files * fix ci fail
This commit is contained in:
parent
2932b39c88
commit
1e11c83e74
24
.bundle-analyzerrc
Normal file
24
.bundle-analyzerrc
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"files": [
|
||||
{
|
||||
"test": "./dist/antd.min.js",
|
||||
"maxSize": "300 kB",
|
||||
"compression": "gzip"
|
||||
},
|
||||
{
|
||||
"test": "./dist/antd.min.css",
|
||||
"maxSize": "65 kB",
|
||||
"compression": "gzip"
|
||||
},
|
||||
{
|
||||
"test": "./dist/antd.dark.min.css",
|
||||
"maxSize": "65 kB",
|
||||
"compression": "gzip"
|
||||
},
|
||||
{
|
||||
"test": "./dist/antd.compact.min.css",
|
||||
"maxSize": "65 kB",
|
||||
"compression": "gzip"
|
||||
}
|
||||
]
|
||||
}
|
@ -153,6 +153,7 @@
|
||||
"@ant-design/colors": "^4.0.0",
|
||||
"@ant-design/hitu": "^0.0.0-alpha.13",
|
||||
"@ant-design/tools": "^8.2.0",
|
||||
"@bundle-analyzer/webpack-plugin": "^0.5.1",
|
||||
"@qixian.cs/github-contributors-list": "^1.0.3",
|
||||
"@stackblitz/sdk": "^1.3.0",
|
||||
"@types/classnames": "^2.2.8",
|
||||
|
@ -3,6 +3,7 @@
|
||||
const getWebpackConfig = require('@ant-design/tools/lib/getWebpackConfig');
|
||||
const IgnoreEmitPlugin = require('ignore-emit-webpack-plugin');
|
||||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
||||
const BundleAnalyzerPluginCom = require('@bundle-analyzer/webpack-plugin');
|
||||
const EsbuildPlugin = require('esbuild-webpack-plugin').default;
|
||||
const darkVars = require('./scripts/dark-vars');
|
||||
const compactVars = require('./scripts/compact-vars');
|
||||
@ -52,6 +53,17 @@ function injectWarningCondition(config) {
|
||||
});
|
||||
}
|
||||
|
||||
function addBundleAnalyzerPluginCom(config) {
|
||||
if (!process.env.CIRCLECI || process.env.RUN_ENV !== 'PRODUCTION') {
|
||||
return;
|
||||
}
|
||||
config.plugins.push(
|
||||
new BundleAnalyzerPluginCom({
|
||||
token: process.env.BUNDLE_ANALYZER_TOKEN,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
function processWebpackThemeConfig(themeConfig, theme, vars) {
|
||||
themeConfig.forEach(config => {
|
||||
ignoreMomentLocale(config);
|
||||
@ -79,6 +91,8 @@ function processWebpackThemeConfig(themeConfig, theme, vars) {
|
||||
const themeReg = new RegExp(`${theme}(.min)?\\.js(\\.map)?$`);
|
||||
// ignore emit ${theme} entry js & js.map file
|
||||
config.plugins.push(new IgnoreEmitPlugin(themeReg));
|
||||
|
||||
addBundleAnalyzerPluginCom(config);
|
||||
});
|
||||
}
|
||||
|
||||
@ -102,16 +116,15 @@ if (process.env.RUN_ENV === 'PRODUCTION') {
|
||||
config.optimization.minimizer[0] = new EsbuildPlugin();
|
||||
}
|
||||
|
||||
// skip codesandbox ci
|
||||
if (!process.env.CSB_REPO) {
|
||||
config.plugins.push(
|
||||
new BundleAnalyzerPlugin({
|
||||
analyzerMode: 'static',
|
||||
openAnalyzer: false,
|
||||
reportFilename: '../report.html',
|
||||
}),
|
||||
);
|
||||
}
|
||||
config.plugins.push(
|
||||
new BundleAnalyzerPlugin({
|
||||
analyzerMode: 'static',
|
||||
openAnalyzer: false,
|
||||
reportFilename: '../report.html',
|
||||
}),
|
||||
);
|
||||
|
||||
addBundleAnalyzerPluginCom(config);
|
||||
});
|
||||
|
||||
processWebpackThemeConfig(webpackDarkConfig, 'dark', darkVars);
|
||||
|
Loading…
Reference in New Issue
Block a user