| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- const CompressionPlugin = require('compression-webpack-plugin');
- const webpack = require('webpack');
- const WebpackBar = require('webpackbar');
- module.exports = {
- // transpileDependencies:[`/minimatch/`,`@babel/plugin-transform-private-methods`],
- publicPath: '/mvue',
- runtimeCompiler: true,
- configureWebpack: config => {
- config.plugins = [
- ...config.plugins,
- new WebpackBar({
- name: 'eip-manage',
- }),
- new webpack.IgnorePlugin({
- resourceRegExp: /^\.\/locale$/,
- contextRegExp: /moment$/
- })
- ]
- if (process.env.NODE_ENV === 'production') {
- // gzip压缩
- config.plugins = [
- ...config.plugins,
- new CompressionPlugin({
- // 要压缩的文件类型
- test: /\.js$|\.html$|\.css/,
- // 大于该尺寸的文件才压缩(单位byte)
- threshold: 10240,
- // 是否删除原文件
- deleteOriginalAssets: false
- }),
- ];
- }
- },
- chainWebpack: config => {
- config.plugins.delete('preload')
- config.plugins.delete('prefetch')
- config.devServer.disableHostCheck(true);
- config.entry('index').add('babel-polyfill');
- if (process.env.NODE_ENV === 'production') {
- config.performance.set('hints', false)
- config.devtool('none')
- // 配置打包时分包的数量上限和单个文件的最小尺寸
- config.optimization.splitChunks({
- chunks: 'all',
- cacheGroups: {
- elementUI: {
- name: 'chunk-elementUI',
- priority: 20,
- test: /[\\/]node_modules[\\/]_?element-ui(.*)/,
- },
- hotentUI: {
- name: 'chunk-hotentUI',
- priority: 20,
- test: /[\\/]node_modules[\\/]_?hotent-ui(.*)/,
- },
- },
- })
- }
- // bpmnlink
- config.module
- .rule('bpmn')
- .test(/\.bpmn$/)
- .use('raw-loader')
- .loader('raw-loader')
- .tap(options => {
- // 修改它的选项...
- return options
- })
- // bpmnlink
- config.module
- .rule('bpmnlint')
- .test(/\.bpmnlintrc$/)
- .use('bpmnlint-loader')
- .loader('bpmnlint-loader')
- .tap(options => {
- // 修改它的选项...
- return options
- })
- },
- // 不生成sourceMap
- productionSourceMap: false,
- css: {
- loaderOptions: {
- sass: {
- prependData: `@import "~@/assets/css/element-variables.scss";`
- },
- },
- },
- }
|