123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- import * as IWebpackChainConfig from 'webpack-chain';
- const webpackPlugin = (config: IWebpackChainConfig) => {
- config.merge({
- optimization: {
- minimize: true,
- splitChunks: {
- chunks: 'async',
- minSize: 30000,
- minChunks: 2,
- automaticNameDelimiter: '.',
- cacheGroups: {
- vendor: {
- name: 'vendors',
- test: /^.*node_modules[\\/](?!ag-grid-|lodash|wangeditor|react-virtualized|rc-select|rc-drawer|rc-time-picker|rc-tree|rc-table|rc-calendar|antd).*$/,
- chunks: "all",
- priority: 10,
- },
- virtualized: {
- name: "virtualized",
- test: /[\\/]node_modules[\\/]react-virtualized/,
- chunks: "all",
- priority: 10
- },
- rcselect: {
- name: "rc-select",
- test: /[\\/]node_modules[\\/]rc-select/,
- chunks: "all",
- priority: 10
- },
- rcdrawer: {
- name: "rcdrawer",
- test: /[\\/]node_modules[\\/]rc-drawer/,
- chunks: "all",
- priority: 10
- },
- rctimepicker: {
- name: "rctimepicker",
- test: /[\\/]node_modules[\\/]rc-time-picker/,
- chunks: "all",
- priority: 10
- },
- ag: {
- name: "ag",
- test: /[\\/]node_modules[\\/]ag-grid-/,
- chunks: "all",
- priority: 10
- },
- antd: {
- name: "antd",
- test: /[\\/]node_modules[\\/]antd[\\/]/,
- chunks: "all",
- priority: 9
- },
- rctree: {
- name: "rctree",
- test: /[\\/]node_modules[\\/]rc-tree/,
- chunks: "all",
- priority: -1
- },
- rccalendar: {
- name: "rccalendar",
- test: /[\\/]node_modules[\\/]rc-calendar[\\/]/,
- chunks: "all",
- priority: -1
- },
- rctable: {
- name: "rctable",
- test: /[\\/]node_modules[\\/]rc-table[\\/]es[\\/]/,
- chunks: "all",
- priority: -1
- },
- wang: {
- name: "wang",
- test: /[\\/]node_modules[\\/]wangeditor[\\/]/,
- chunks: "all",
- priority: -1
- },
- lodash: {
- name: "lodash",
- test: /[\\/]node_modules[\\/]lodash[\\/]/,
- chunks: "all",
- priority: -2
- },
- bizcharts: {
- name: "bizcharts",
- test: /[\\/]node_modules[\\/]bizcharts[\\/]/,
- chunks: "all",
- priority: 10
- },
- xlsx: {
- name: "xlsx",
- test: /[\\/]node_modules[\\/]xlsx[\\/]/,
- chunks: "async",
- priority: 10
- }
- }
- }
- }
- });
- //过滤掉momnet的那些不使用的国际化文件
- config.plugin("replace").use(require("webpack").ContextReplacementPlugin).tap(() => {
- return [/moment[/\\]locale$/, /zh-cn/];
- });
- };
- export default webpackPlugin;
|