|
@@ -8,6 +8,12 @@ const CompressionWebpackPlugin = require('compression-webpack-plugin');
|
|
const prodGzipList = ['js', 'css'];
|
|
const prodGzipList = ['js', 'css'];
|
|
|
|
|
|
export default config => {
|
|
export default config => {
|
|
|
|
+ // config.module
|
|
|
|
+ // .rule()
|
|
|
|
+ // .test(/\.(pdf|svg|docx|doc)$/)
|
|
|
|
+ // .use('file-loader?name=[path][name].[ext]')
|
|
|
|
+ // .loader('file-loader')
|
|
|
|
+ // .end();
|
|
// pro 和 开发环境再添加这个插件
|
|
// pro 和 开发环境再添加这个插件
|
|
if (process.env.APP_TYPE === 'site' || process.env.NODE_ENV !== 'production') {
|
|
if (process.env.APP_TYPE === 'site' || process.env.NODE_ENV !== 'production') {
|
|
// 将所有 less 合并为一个供 themePlugin使用
|
|
// 将所有 less 合并为一个供 themePlugin使用
|
|
@@ -45,7 +51,7 @@ export default config => {
|
|
// return chunk.name !== 'my-excluded-chunk';
|
|
// return chunk.name !== 'my-excluded-chunk';
|
|
// },
|
|
// },
|
|
minSize: 20000, //生成块的最小大小(以字节为单位)1024字节=1KB。
|
|
minSize: 20000, //生成块的最小大小(以字节为单位)1024字节=1KB。
|
|
- minChunks: 1, //拆分前必须共享模块的最小块数。
|
|
|
|
|
|
+ minChunks: 1, //拆分前必须共享模块的最小块数。
|
|
maxInitialRequests: 30, //入口点的最大并行请求数。
|
|
maxInitialRequests: 30, //入口点的最大并行请求数。
|
|
automaticNameDelimiter: '.',
|
|
automaticNameDelimiter: '.',
|
|
cacheGroups: {
|
|
cacheGroups: {
|
|
@@ -56,12 +62,12 @@ export default config => {
|
|
enforce: true,
|
|
enforce: true,
|
|
},
|
|
},
|
|
virtualized: {
|
|
virtualized: {
|
|
- name: "virtualized",
|
|
|
|
|
|
+ name: 'virtualized',
|
|
test: /[\\/]node_modules[\\/]react-virtualized/,
|
|
test: /[\\/]node_modules[\\/]react-virtualized/,
|
|
priority: 10,
|
|
priority: 10,
|
|
},
|
|
},
|
|
antd: {
|
|
antd: {
|
|
- name: "antd",
|
|
|
|
|
|
+ name: 'antd',
|
|
test: /[\\/]node_modules[\\/]antd[\\/]/,
|
|
test: /[\\/]node_modules[\\/]antd[\\/]/,
|
|
priority: 9,
|
|
priority: 9,
|
|
},
|
|
},
|
|
@@ -70,23 +76,24 @@ export default config => {
|
|
// test: /[\\/]node_modules[\\/]@antv[\\/]/,
|
|
// test: /[\\/]node_modules[\\/]@antv[\\/]/,
|
|
// priority: 9,
|
|
// priority: 9,
|
|
// },
|
|
// },
|
|
- echarts: { // 1.27MB
|
|
|
|
- name: "echarts",
|
|
|
|
|
|
+ echarts: {
|
|
|
|
+ // 1.27MB
|
|
|
|
+ name: 'echarts',
|
|
test: /[\\/]node_modules[\\/](echarts|echarts-gl)[\\/]/,
|
|
test: /[\\/]node_modules[\\/](echarts|echarts-gl)[\\/]/,
|
|
priority: 10,
|
|
priority: 10,
|
|
enforce: true,
|
|
enforce: true,
|
|
},
|
|
},
|
|
bizcharts: {
|
|
bizcharts: {
|
|
- name: "bizcharts",
|
|
|
|
|
|
+ name: 'bizcharts',
|
|
test: /[\\/]node_modules[\\/]bizcharts[\\/]/,
|
|
test: /[\\/]node_modules[\\/]bizcharts[\\/]/,
|
|
- chunks: "all",
|
|
|
|
- priority: 10
|
|
|
|
|
|
+ chunks: 'all',
|
|
|
|
+ priority: 10,
|
|
},
|
|
},
|
|
hlsJs: {
|
|
hlsJs: {
|
|
- name: "hlsJs",
|
|
|
|
|
|
+ name: 'hlsJs',
|
|
test: /[\\/]node_modules[\\/]hls.js[\\/]/,
|
|
test: /[\\/]node_modules[\\/]hls.js[\\/]/,
|
|
- chunks: "all",
|
|
|
|
- priority: 10
|
|
|
|
|
|
+ chunks: 'all',
|
|
|
|
+ priority: 10,
|
|
},
|
|
},
|
|
// moment: {
|
|
// moment: {
|
|
// name: "moment",
|
|
// name: "moment",
|
|
@@ -95,22 +102,22 @@ export default config => {
|
|
// priority: 10
|
|
// priority: 10
|
|
// },
|
|
// },
|
|
fileManage: {
|
|
fileManage: {
|
|
- name: "fileManage",
|
|
|
|
|
|
+ name: 'fileManage',
|
|
test: /[\\/]node_modules[\\/]@opuscapita[\\/]/,
|
|
test: /[\\/]node_modules[\\/]@opuscapita[\\/]/,
|
|
- chunks: "all",
|
|
|
|
- priority: 10
|
|
|
|
|
|
+ chunks: 'all',
|
|
|
|
+ priority: 10,
|
|
},
|
|
},
|
|
pdfJs: {
|
|
pdfJs: {
|
|
- name: "pdfjs-dist",
|
|
|
|
|
|
+ name: 'pdfjs-dist',
|
|
test: /[\\/]node_modules[\\/]pdfjs-dist[\\/]/,
|
|
test: /[\\/]node_modules[\\/]pdfjs-dist[\\/]/,
|
|
- chunks: "all",
|
|
|
|
- priority: 10
|
|
|
|
|
|
+ chunks: 'all',
|
|
|
|
+ priority: 10,
|
|
},
|
|
},
|
|
ggEditor: {
|
|
ggEditor: {
|
|
- name: "ggEditor",
|
|
|
|
|
|
+ name: 'ggEditor',
|
|
test: /[\\/]node_modules[\\/]gg-editor-core[\\/]/,
|
|
test: /[\\/]node_modules[\\/]gg-editor-core[\\/]/,
|
|
- chunks: "all",
|
|
|
|
- priority: 10
|
|
|
|
|
|
+ chunks: 'all',
|
|
|
|
+ priority: 10,
|
|
},
|
|
},
|
|
// zrender: {
|
|
// zrender: {
|
|
// name: "zrender",
|
|
// name: "zrender",
|
|
@@ -119,22 +126,22 @@ export default config => {
|
|
// priority: 10
|
|
// priority: 10
|
|
// },
|
|
// },
|
|
swiper: {
|
|
swiper: {
|
|
- name: "swiper",
|
|
|
|
|
|
+ name: 'swiper',
|
|
test: /[\\/]node_modules[\\/]swiper[\\/]/,
|
|
test: /[\\/]node_modules[\\/]swiper[\\/]/,
|
|
- chunks: "all",
|
|
|
|
- priority: 10
|
|
|
|
|
|
+ chunks: 'all',
|
|
|
|
+ priority: 10,
|
|
},
|
|
},
|
|
flv: {
|
|
flv: {
|
|
- name: "flv",
|
|
|
|
|
|
+ name: 'flv',
|
|
test: /[\\/]node_modules[\\/]flv.js[\\/]/,
|
|
test: /[\\/]node_modules[\\/]flv.js[\\/]/,
|
|
- chunks: "all",
|
|
|
|
- priority: 10
|
|
|
|
|
|
+ chunks: 'all',
|
|
|
|
+ priority: 10,
|
|
},
|
|
},
|
|
xlsx: {
|
|
xlsx: {
|
|
- name: "xlsx",
|
|
|
|
|
|
+ name: 'xlsx',
|
|
test: /[\\/]node_modules[\\/]xlsx[\\/]/,
|
|
test: /[\\/]node_modules[\\/]xlsx[\\/]/,
|
|
- chunks: "async",
|
|
|
|
- priority: 10
|
|
|
|
|
|
+ chunks: 'async',
|
|
|
|
+ priority: 10,
|
|
},
|
|
},
|
|
// rctree: {
|
|
// rctree: {
|
|
|
|
|
|
@@ -151,11 +158,10 @@ export default config => {
|
|
// priority: -1
|
|
// priority: -1
|
|
// },
|
|
// },
|
|
wang: {
|
|
wang: {
|
|
-
|
|
|
|
- name: "wang",
|
|
|
|
|
|
+ name: 'wang',
|
|
test: /[\\/]node_modules[\\/]wangeditor[\\/]/,
|
|
test: /[\\/]node_modules[\\/]wangeditor[\\/]/,
|
|
- chunks: "all",
|
|
|
|
- priority: -1
|
|
|
|
|
|
+ chunks: 'all',
|
|
|
|
+ priority: -1,
|
|
},
|
|
},
|
|
// lodash: {
|
|
// lodash: {
|
|
|
|
|
|
@@ -172,13 +178,12 @@ export default config => {
|
|
// priority: 10
|
|
// priority: 10
|
|
// },
|
|
// },
|
|
ag: {
|
|
ag: {
|
|
-
|
|
|
|
- name: "ag",
|
|
|
|
|
|
+ name: 'ag',
|
|
test: /[\\/]node_modules[\\/]ag-grid-/,
|
|
test: /[\\/]node_modules[\\/]ag-grid-/,
|
|
- chunks: "all",
|
|
|
|
- priority: 10
|
|
|
|
|
|
+ chunks: 'all',
|
|
|
|
+ priority: 10,
|
|
},
|
|
},
|
|
- }
|
|
|
|
|
|
+ },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|
|
});
|
|
@@ -192,15 +197,17 @@ export default config => {
|
|
algorithm: 'gzip', // 指定生成gzip格式
|
|
algorithm: 'gzip', // 指定生成gzip格式
|
|
test: new RegExp('\\.(' + prodGzipList.join('|') + ')$'), // 匹配哪些格式文件需要压缩
|
|
test: new RegExp('\\.(' + prodGzipList.join('|') + ')$'), // 匹配哪些格式文件需要压缩
|
|
threshold: 10240, //对超过10k的数据进行压缩
|
|
threshold: 10240, //对超过10k的数据进行压缩
|
|
- minRatio: 0.6 // 压缩比例,值为0 ~ 1
|
|
|
|
|
|
+ minRatio: 0.6, // 压缩比例,值为0 ~ 1
|
|
})
|
|
})
|
|
);
|
|
);
|
|
}
|
|
}
|
|
//过滤掉momnet的那些不使用的国际化文件
|
|
//过滤掉momnet的那些不使用的国际化文件
|
|
- config.plugin("replace").use(require("webpack").ContextReplacementPlugin).tap(() => {
|
|
|
|
-
|
|
|
|
- return [/moment[/\\]locale$/, /zh-cn/];
|
|
|
|
- });
|
|
|
|
|
|
+ config
|
|
|
|
+ .plugin('replace')
|
|
|
|
+ .use(require('webpack').ContextReplacementPlugin)
|
|
|
|
+ .tap(() => {
|
|
|
|
+ return [/moment[/\\]locale$/, /zh-cn/];
|
|
|
|
+ });
|
|
|
|
|
|
// config.output.filename = '[name].[contenthash].js'
|
|
// config.output.filename = '[name].[contenthash].js'
|
|
};
|
|
};
|