chore: update webpack

pull/4499/head
tangjinzhou 2021-08-09 21:49:57 +08:00
parent 553554d72f
commit 02b934c33d
6 changed files with 56 additions and 37 deletions

2
.gitignore vendored
View File

@ -73,3 +73,5 @@ site/dev.js
# IDE 语法提示临时文件
vetur/
report.html

View File

@ -8,16 +8,17 @@ import { withInstall } from '../_util/type';
import type { ValidateMessages } from '../form/interface';
import type { TransferLocale } from '../transfer';
import type { PickerLocale as DatePickerLocale } from '../date-picker/generatePicker';
import { PaginationLocale } from '../pagination/Pagination';
interface TransferLocaleForEmpty {
description: string;
}
export interface Locale {
locale: string;
Pagination?: Object;
Table?: Object;
Popconfirm?: Object;
Upload?: Object;
Pagination?: PaginationLocale;
Table?: Record<string, any>;
Popconfirm?: Record<string, any>;
Upload?: Record<string, any>;
Form?: {
optional?: string;
defaultValidateMessages: ValidateMessages;
@ -72,9 +73,9 @@ const LocaleProvider = defineComponent({
() => props.locale,
val => {
state.antLocale = {
...val,
...props.locale,
exist: true,
};
} as any;
changeConfirmLocale(val && val.Modal);
},
{ immediate: true },

View File

@ -51,6 +51,7 @@ export const paginationConfig = () => ({
export type PaginationProps = Partial<ExtractPropTypes<ReturnType<typeof paginationProps>>>;
export type PaginationConfig = Partial<ExtractPropTypes<ReturnType<typeof paginationConfig>>>;
export type PaginationLocale = any;
export default defineComponent({
name: 'APagination',
inheritAttrs: false,

View File

@ -212,7 +212,7 @@ export default defineComponent({
if (!!filterOption === false) {
return true;
}
return filterOption(targetMeasureText, option);
return (filterOption as Function)(targetMeasureText, option);
});
return list;
};

View File

@ -195,7 +195,7 @@
"vue-style-loader": "^4.1.2",
"vuex": "^4.0.0-beta.2",
"webpack": "^5.0.0",
"webpack-bundle-analyzer": "^4.0.0",
"webpack-bundle-analyzer": "^4.4.2",
"webpack-cli": "^4.6.0",
"webpack-dev-server": "^3.1.14",
"webpack-merge": "^5.0.0",

View File

@ -1,4 +1,5 @@
// This config is for building dist files
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const getWebpackConfig = require('./antd-tools/getWebpackConfig');
const IgnoreEmitPlugin = require('ignore-emit-webpack-plugin');
const darkVars = require('./scripts/dark-vars');
@ -21,41 +22,55 @@ function externalDayjs(config) {
};
}
function processWebpackThemeConfig(themeConfig, theme, vars) {
themeConfig.forEach(config => {
externalDayjs(config);
// rename default entry to ${theme} entry
Object.keys(config.entry).forEach(entryName => {
config.entry[entryName.replace('antd', `antd.${theme}`)] = config.entry[entryName];
delete config.entry[entryName];
});
// apply ${theme} less variables
config.module.rules.forEach(rule => {
// filter less rule
if (rule.test instanceof RegExp && rule.test.test('.less')) {
const lessRule = rule.use[rule.use.length - 1];
if (lessRule.options.lessOptions) {
lessRule.options.lessOptions.modifyVars = vars;
} else {
lessRule.options.modifyVars = vars;
}
}
});
const themeReg = new RegExp(`${theme}(.min)?\\.js(\\.map)?$`);
// ignore emit ${theme} entry js & js.map file
config.plugins.push(new IgnoreEmitPlugin(themeReg));
});
}
const webpackConfig = getWebpackConfig(false);
const webpackDarkConfig = getWebpackConfig(false);
if (process.env.RUN_ENV === 'PRODUCTION') {
webpackConfig.forEach(config => {
externalDayjs(config);
addLocales(config);
// Reduce non-minified dist files size
config.optimization.usedExports = true;
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: false,
reportFilename: '../report.html',
}),
);
});
processWebpackThemeConfig(webpackDarkConfig, 'dark', darkVars);
}
const webpackDarkConfig = getWebpackConfig(false);
webpackDarkConfig.forEach(config => {
externalDayjs(config);
// rename default entry to ${theme} entry
Object.keys(config.entry).forEach(entryName => {
config.entry[entryName.replace('antd', `antd.dark`)] = config.entry[entryName];
delete config.entry[entryName];
});
// apply ${theme} less variables
config.module.rules.forEach(rule => {
// filter less rule
if (rule.test instanceof RegExp && rule.test.test('.less')) {
const lessRule = rule.use[rule.use.length - 1];
if (lessRule.options.lessOptions) {
lessRule.options.lessOptions.modifyVars = darkVars;
} else {
lessRule.options.modifyVars = darkVars;
}
}
});
const themeReg = new RegExp(`dark(.min)?\\.js(\\.map)?`);
// ignore emit ${theme} entry js & js.map file
config.plugins.push(new IgnoreEmitPlugin(themeReg));
});
module.exports = webpackConfig.concat(webpackDarkConfig);