vue.config.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. const CompressionPlugin = require('compression-webpack-plugin');
  2. const webpack = require('webpack');
  3. const WebpackBar = require('webpackbar');
  4. module.exports = {
  5. // transpileDependencies:[`/minimatch/`,`@babel/plugin-transform-private-methods`],
  6. publicPath: '/mvue',
  7. runtimeCompiler: true,
  8. configureWebpack: config => {
  9. config.plugins = [
  10. ...config.plugins,
  11. new WebpackBar({
  12. name: 'eip-manage',
  13. }),
  14. new webpack.IgnorePlugin({
  15. resourceRegExp: /^\.\/locale$/,
  16. contextRegExp: /moment$/
  17. })
  18. ]
  19. if (process.env.NODE_ENV === 'production') {
  20. // gzip压缩
  21. config.plugins = [
  22. ...config.plugins,
  23. new CompressionPlugin({
  24. // 要压缩的文件类型
  25. test: /\.js$|\.html$|\.css/,
  26. // 大于该尺寸的文件才压缩(单位byte)
  27. threshold: 10240,
  28. // 是否删除原文件
  29. deleteOriginalAssets: false
  30. }),
  31. ];
  32. }
  33. },
  34. chainWebpack: config => {
  35. config.plugins.delete('preload')
  36. config.plugins.delete('prefetch')
  37. config.devServer.disableHostCheck(true);
  38. config.entry('index').add('babel-polyfill');
  39. if (process.env.NODE_ENV === 'production') {
  40. config.performance.set('hints', false)
  41. config.devtool('none')
  42. // 配置打包时分包的数量上限和单个文件的最小尺寸
  43. config.optimization.splitChunks({
  44. chunks: 'all',
  45. cacheGroups: {
  46. elementUI: {
  47. name: 'chunk-elementUI',
  48. priority: 20,
  49. test: /[\\/]node_modules[\\/]_?element-ui(.*)/,
  50. },
  51. hotentUI: {
  52. name: 'chunk-hotentUI',
  53. priority: 20,
  54. test: /[\\/]node_modules[\\/]_?hotent-ui(.*)/,
  55. },
  56. },
  57. })
  58. }
  59. // bpmnlink
  60. config.module
  61. .rule('bpmn')
  62. .test(/\.bpmn$/)
  63. .use('raw-loader')
  64. .loader('raw-loader')
  65. .tap(options => {
  66. // 修改它的选项...
  67. return options
  68. })
  69. // bpmnlink
  70. config.module
  71. .rule('bpmnlint')
  72. .test(/\.bpmnlintrc$/)
  73. .use('bpmnlint-loader')
  74. .loader('bpmnlint-loader')
  75. .tap(options => {
  76. // 修改它的选项...
  77. return options
  78. })
  79. },
  80. // 不生成sourceMap
  81. productionSourceMap: false,
  82. css: {
  83. loaderOptions: {
  84. sass: {
  85. prependData: `@import "~@/assets/css/element-variables.scss";`
  86. },
  87. },
  88. },
  89. }