|
@@ -2,7 +2,7 @@
|
|
|
|
|
|
|
|
const CompressionWebpackPlugin = require('compression-webpack-plugin')
|
|
const CompressionWebpackPlugin = require('compression-webpack-plugin')
|
|
|
const AntdDayjsWebpackPlugin = require('antd-dayjs-webpack-plugin')
|
|
const AntdDayjsWebpackPlugin = require('antd-dayjs-webpack-plugin')
|
|
|
-const prodGzipList = ['js', 'css']
|
|
|
|
|
|
|
+const prodGzipList = ['js', 'css', 'html']
|
|
|
|
|
|
|
|
import { defineConfig } from 'umi'
|
|
import { defineConfig } from 'umi'
|
|
|
import defaultSettings from './defaultSettings'
|
|
import defaultSettings from './defaultSettings'
|
|
@@ -90,130 +90,54 @@ export default defineConfig({
|
|
|
'@arco-design/web-react'
|
|
'@arco-design/web-react'
|
|
|
]
|
|
]
|
|
|
],
|
|
],
|
|
|
- chunks: ['vendors', 'umi'],
|
|
|
|
|
chainWebpack(config) {
|
|
chainWebpack(config) {
|
|
|
config.plugin('windicss').use(windicss)
|
|
config.plugin('windicss').use(windicss)
|
|
|
config.plugin('antd-dayjs-webpack-plugin').use(AntdDayjsWebpackPlugin)
|
|
config.plugin('antd-dayjs-webpack-plugin').use(AntdDayjsWebpackPlugin)
|
|
|
|
|
|
|
|
- // if (REACT_APP_ENV === 'prod') {
|
|
|
|
|
- config.merge({
|
|
|
|
|
- optimization: {
|
|
|
|
|
- minimize: true,
|
|
|
|
|
- splitChunks: {
|
|
|
|
|
- chunks: 'async',
|
|
|
|
|
- minSize: 30000,
|
|
|
|
|
- minChunks: 3,
|
|
|
|
|
- automaticNameDelimiter: '.',
|
|
|
|
|
- cacheGroups: {
|
|
|
|
|
- react: {
|
|
|
|
|
- name: 'react',
|
|
|
|
|
- priority: 10,
|
|
|
|
|
- test: /[\\/]node_modules[\\/](react|react-dom|react-dom-router)[\\/]/
|
|
|
|
|
- },
|
|
|
|
|
- vendor: {
|
|
|
|
|
- name: 'vendors',
|
|
|
|
|
- test({ resource }) {
|
|
|
|
|
- return /[\\/]node_modules[\\/]/.test(resource)
|
|
|
|
|
|
|
+ if (REACT_APP_ENV === 'prod') {
|
|
|
|
|
+ config.merge({
|
|
|
|
|
+ optimization: {
|
|
|
|
|
+ minimize: true,
|
|
|
|
|
+ splitChunks: {
|
|
|
|
|
+ chunks: 'all',
|
|
|
|
|
+ minSize: 30000,
|
|
|
|
|
+ minChunks: 2,
|
|
|
|
|
+ automaticNameDelimiter: '.',
|
|
|
|
|
+ cacheGroups: {
|
|
|
|
|
+ vendor: {
|
|
|
|
|
+ name: 'vendors',
|
|
|
|
|
+ test: ({ resource }) => /^.(?=lodash-es|antd|react).$/.test(resource),
|
|
|
|
|
+ chunks: 'all',
|
|
|
|
|
+ priority: 20
|
|
|
},
|
|
},
|
|
|
- priority: 10
|
|
|
|
|
- },
|
|
|
|
|
- antd: {
|
|
|
|
|
- name: 'antd',
|
|
|
|
|
- test: /[\\/]node_modules[\\/]antd/,
|
|
|
|
|
- chunks: 'all',
|
|
|
|
|
- priority: 9
|
|
|
|
|
- },
|
|
|
|
|
- chart: {
|
|
|
|
|
- name: 'chart',
|
|
|
|
|
- chunks: 'all',
|
|
|
|
|
- test: /[\\/]node_modules[\\/]@ant-design[\\/]charts/,
|
|
|
|
|
- priority: 11
|
|
|
|
|
- },
|
|
|
|
|
- icons: {
|
|
|
|
|
- name: 'icons',
|
|
|
|
|
- chunks: 'all',
|
|
|
|
|
- test: /[\\/]node_modules[\\/]@ant-design[\\/]icons/,
|
|
|
|
|
- priority: 10
|
|
|
|
|
- },
|
|
|
|
|
- 'pro-table': {
|
|
|
|
|
- name: 'pro-table',
|
|
|
|
|
- chunks: 'all',
|
|
|
|
|
- test: /[\\/]node_modules[\\/]@ant-design[\\/]pro-table/,
|
|
|
|
|
- priority: -1
|
|
|
|
|
- },
|
|
|
|
|
- 'pro-layout': {
|
|
|
|
|
- name: 'pro-layout',
|
|
|
|
|
- chunks: 'all',
|
|
|
|
|
- test: /[\\/]node_modules[\\/]@ant-design[\\/]pro-layout/,
|
|
|
|
|
- priority: -1
|
|
|
|
|
- },
|
|
|
|
|
- 'pro-form': {
|
|
|
|
|
- name: 'pro-form',
|
|
|
|
|
- chunks: 'all',
|
|
|
|
|
- test: /[\\/]node_modules[\\/]@ant-design[\\/]pro-form/,
|
|
|
|
|
- priority: 10
|
|
|
|
|
- },
|
|
|
|
|
- 'icon-park': {
|
|
|
|
|
- name: 'icon-park',
|
|
|
|
|
- chunks: 'all',
|
|
|
|
|
- test: /[\\/]node_modules[\\/]@icon-park[\\/]react/,
|
|
|
|
|
- priority: 10
|
|
|
|
|
- },
|
|
|
|
|
- 'arco-design': {
|
|
|
|
|
- name: 'arco-design',
|
|
|
|
|
- chunks: 'all',
|
|
|
|
|
- test: /[\\/]node_modules[\\/]@arco-design[\\/]web-react/,
|
|
|
|
|
- priority: 11
|
|
|
|
|
- },
|
|
|
|
|
- lodash: {
|
|
|
|
|
- name: 'lodash',
|
|
|
|
|
- test: /[\\/]node_modules[\\/]lodash-es[\\/]/,
|
|
|
|
|
- chunks: 'all',
|
|
|
|
|
- priority: -2
|
|
|
|
|
- },
|
|
|
|
|
- jsdk: {
|
|
|
|
|
- name: 'jsdk',
|
|
|
|
|
- chunks: 'initial',
|
|
|
|
|
- test: /[\\/]node_modules[\\/](dayjs|react-copy-to-clipboard|react-infinite-scroll-component)[\\/]/,
|
|
|
|
|
- priority: 11
|
|
|
|
|
- },
|
|
|
|
|
- markdown: {
|
|
|
|
|
- name: 'markdown',
|
|
|
|
|
- test: /[\\/]node_modules[\\/]react-markdown/,
|
|
|
|
|
- priority: 12
|
|
|
|
|
- },
|
|
|
|
|
- vditor: {
|
|
|
|
|
- name: 'vditor',
|
|
|
|
|
- test: /[\\/]node_modules[\\/]vditor[\\/]/,
|
|
|
|
|
- priority: 12
|
|
|
|
|
- },
|
|
|
|
|
- 'async-commons': {
|
|
|
|
|
- // 其余异步加载包
|
|
|
|
|
- chunks: 'async',
|
|
|
|
|
- minChunks: 2,
|
|
|
|
|
- name: 'async-commons',
|
|
|
|
|
- priority: 9
|
|
|
|
|
- },
|
|
|
|
|
- default: {
|
|
|
|
|
- name: 'default',
|
|
|
|
|
- minChunks: 1,
|
|
|
|
|
- priority: -1,
|
|
|
|
|
- reuseExistingChunk: true
|
|
|
|
|
|
|
+ antd: {
|
|
|
|
|
+ name: 'antd',
|
|
|
|
|
+ test: ({ resource }) => /^.antd.$/.test(resource),
|
|
|
|
|
+ chunks: 'all',
|
|
|
|
|
+ priority: 10,
|
|
|
|
|
+ reuseExistingChunk: true
|
|
|
|
|
+ },
|
|
|
|
|
+ markdown: {
|
|
|
|
|
+ name: 'markdown',
|
|
|
|
|
+ test: ({ resource }) => /^.(?=react-markdown|vditor).$/.test(resource),
|
|
|
|
|
+ chunks: 'all',
|
|
|
|
|
+ priority: 9,
|
|
|
|
|
+ reuseExistingChunk: true
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- // config.plugin('compression-webpack-plugin').use(
|
|
|
|
|
- // new CompressionWebpackPlugin({
|
|
|
|
|
- // // filename: 文件名称,这里我们不设置,让它保持和未压缩的文件同一个名称
|
|
|
|
|
- // algorithm: 'gzip', // 指定生成gzip格式
|
|
|
|
|
- // test: new RegExp('\\.(' + prodGzipList.join('|') + ')$'), // 匹配哪些格式文件需要压缩
|
|
|
|
|
- // threshold: 5000, //对超过10k的数据进行压缩
|
|
|
|
|
- // minRatio: 0.6 // 压缩比例,值为0 ~ 1
|
|
|
|
|
- // })
|
|
|
|
|
- // )
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ })
|
|
|
|
|
+ config.plugin('compression-webpack-plugin').use(
|
|
|
|
|
+ new CompressionWebpackPlugin({
|
|
|
|
|
+ // filename: 文件名称,这里我们不设置,让它保持和未压缩的文件同一个名称
|
|
|
|
|
+ algorithm: 'gzip', // 指定生成gzip格式
|
|
|
|
|
+ test: new RegExp('\\.(' + prodGzipList.join('|') + ')$'), // 匹配哪些格式文件需要压缩
|
|
|
|
|
+ threshold: 5000, //对超过10k的数据进行压缩
|
|
|
|
|
+ minRatio: 0.6 // 压缩比例,值为0 ~ 1
|
|
|
|
|
+ })
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
//过滤掉momnet的那些不使用的国际化文件
|
|
//过滤掉momnet的那些不使用的国际化文件
|
|
|
// config
|
|
// config
|
|
|
// .plugin('replace')
|
|
// .plugin('replace')
|