代码拉取完成,页面将自动刷新
// This config is for building dist files
// const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const { EsbuildPlugin } = require('esbuild-loader');
const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin');
const getWebpackConfig = require('./antd-tools/getWebpackConfig');
function addLocales(webpackConfig) {
let packageName = 'antd-with-locales';
if (webpackConfig.entry['antd.min']) {
packageName += '.min';
}
webpackConfig.entry[packageName] = './index-with-locales.js';
webpackConfig.output.filename = '[name].js';
}
function externalDayjs(config) {
config.externals.push({
dayjs: {
root: 'dayjs',
commonjs2: 'dayjs',
commonjs: 'dayjs',
amd: 'dayjs',
module: 'dayjs',
},
});
config.externals.push(function ({ _context, request }, callback) {
if (/^dayjs\/plugin\//.test(request)) {
const name = request.replace(/\//g, '_');
return callback(null, {
root: name,
commonjs2: name,
commonjs: name,
amd: name,
module: name,
});
}
callback();
});
}
const webpackConfig = getWebpackConfig(false);
const webpackESMConfig = getWebpackConfig(false, true);
if (process.env.RUN_ENV === 'PRODUCTION') {
webpackConfig.forEach(config => {
addLocales(config);
externalDayjs(config);
// Reduce non-minified dist files size
config.optimization.usedExports = true;
// use esbuild
if (process.env.ESBUILD || process.env.CSB_REPO) {
config.optimization.minimizer[0] = new EsbuildPlugin({
target: 'es2015',
css: true,
});
}
// config.plugins.push(
// new BundleAnalyzerPlugin({
// analyzerMode: 'static',
// openAnalyzer: false,
// reportFilename: '../report.html',
// }),
// );
if (!process.env.NO_DUP_CHECK) {
config.plugins.push(
new DuplicatePackageCheckerPlugin({
verbose: true,
emitError: true,
}),
);
}
});
}
module.exports = [...webpackConfig, ...webpackESMConfig];
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。