const CompressionPlugin = require('compression-webpack-plugin'); const webpack = require('webpack'); const WebpackBar = require('webpackbar'); const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin'); module.exports = { publicPath: '/mvue', runtimeCompiler: true, configureWebpack: config => { config.plugins = [ ...config.plugins, new WebpackBar({ name: 'eip-manage', }), new webpack.IgnorePlugin({ resourceRegExp: /^\.\/locale$/, contextRegExp: /moment$/ }), new MonacoWebpackPlugin({languages: ['javascript', 'css', 'html', 'typescript', 'json', 'java']}) ] 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";` }, }, }, }