vue.config.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. const path = require('path')
  2. const CompressionPlugin = require("compression-webpack-plugin")
  3. function resolve(dir) {
  4. return path.join(__dirname, dir)
  5. }
  6. // vue.config.js
  7. module.exports = {
  8. /*
  9. Vue-cli3:
  10. Crashed when using Webpack `import()` #2463
  11. https://github.com/vuejs/vue-cli/issues/2463
  12. */
  13. // 如果你不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。
  14. productionSourceMap: false,
  15. //qiankuan打包时放开
  16. // outputDir: '/tdzcxx/',
  17. // 多入口配置
  18. // pages: {
  19. // index: {
  20. // entry: 'src/main.js',
  21. // template: 'public/index.html',
  22. // filename: 'index.html',
  23. // }
  24. // },
  25. //打包app时放开该配置
  26. publicPath: '/tdzcxx/',
  27. configureWebpack: config => {
  28. config.externals = {
  29. BMap: 'BMap'
  30. }
  31. //生产环境取消 console.log
  32. if (process.env.NODE_ENV === 'production') {
  33. config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
  34. }
  35. ;
  36. },
  37. chainWebpack: (config) => {
  38. config.resolve.alias
  39. .set('@$', resolve('src'))
  40. .set('@api', resolve('src/api'))
  41. .set('@assets', resolve('src/assets'))
  42. .set('@comp', resolve('src/components'))
  43. .set('@views', resolve('src/views'))
  44. //生产环境,开启js\css压缩
  45. if (process.env.NODE_ENV === 'production') {
  46. config.plugin('compressionPlugin').use(new CompressionPlugin({
  47. test: /\.(js|css|less)$/, // 匹配文件名
  48. threshold: 10240, // 对超过10k的数据压缩
  49. deleteOriginalAssets: false // 不删除源文件
  50. }))
  51. }
  52. // 配置 webpack 识别 markdown 为普通的文件
  53. config.module
  54. .rule('markdown')
  55. .test(/\.md$/)
  56. .use()
  57. .loader('file-loader')
  58. .end()
  59. // 编译vxe-table包里的es6代码,解决IE11兼容问题
  60. config.module
  61. .rule('vxe')
  62. .test(/\.js$/)
  63. .include
  64. .add(resolve('node_modules/vxe-table'))
  65. .add(resolve('node_modules/vxe-table-plugin-antd'))
  66. .end()
  67. .use()
  68. .loader('babel-loader')
  69. .end()
  70. },
  71. css: {
  72. loaderOptions: {
  73. less: {
  74. modifyVars: {
  75. /* less 变量覆盖,用于自定义 ant design 主题 */
  76. 'primary-color': '#3264ff',
  77. 'link-color': '#3264ff',
  78. 'border-radius-base': '4px',
  79. },
  80. javascriptEnabled: true,
  81. }
  82. }
  83. },
  84. devServer: {
  85. port: 3000,
  86. // hot: true,
  87. // disableHostCheck: true,
  88. // overlay: {
  89. // warnings: false,
  90. // errors: true,
  91. // },
  92. // headers: {
  93. // 'Access-Control-Allow-Origin': '*',
  94. // },
  95. proxy: {
  96. /* '/api': {
  97. target: 'https://mock.ihx.me/mock/5baf3052f7da7e07e04a5116/antd-pro', //mock API接口系统
  98. ws: false,
  99. changeOrigin: true,
  100. pathRewrite: {
  101. '/jeecg-boot': '' //默认所有请求都加了jeecg-boot前缀,需要去掉
  102. }
  103. },*/
  104. /* 注意:jeecgboot前端做了改造,此处不需要配置跨域和后台接口(只需要改.env相关配置文件即可)
  105. issues/3462 很多人此处做了配置,导致刷新前端404问题,请一定注意*/
  106. '/jeecg-boot': {
  107. target: 'http://localhost:8080',
  108. ws: false,
  109. changeOrigin: true
  110. },
  111. }
  112. },
  113. lintOnSave: undefined
  114. }