You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

92 lines
2.5 KiB

  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. //打包app时放开该配置
  16. publicPath:'./',
  17. configureWebpack: config => {
  18. //生产环境取消 console.log
  19. if (process.env.NODE_ENV === 'production') {
  20. config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
  21. }
  22. },
  23. chainWebpack: (config) => {
  24. config.resolve.alias
  25. .set('@$', resolve('src'))
  26. .set('@api', resolve('src/api'))
  27. .set('@assets', resolve('src/assets'))
  28. .set('@comp', resolve('src/components'))
  29. .set('@views', resolve('src/views'))
  30. .set('@layout', resolve('src/layout'))
  31. .set('@static', resolve('src/static'))
  32. .set('@mobile', resolve('src/modules/mobile'))
  33. //生产环境,开启js\css压缩
  34. if (process.env.NODE_ENV === 'production') {
  35. config.plugin('compressionPlugin').use(new CompressionPlugin({
  36. test: /\.(js|css|less)$/, // 匹配文件名
  37. threshold: 10240, // 对超过10k的数据压缩
  38. deleteOriginalAssets: false // 不删除源文件
  39. }))
  40. }
  41. // 配置 webpack 识别 markdown 为普通的文件
  42. config.module
  43. .rule('markdown')
  44. .test(/\.md$/)
  45. .use()
  46. .loader('file-loader')
  47. .end()
  48. },
  49. css: {
  50. loaderOptions: {
  51. less: {
  52. modifyVars: {
  53. /* less 变量覆盖,用于自定义 ant design 主题 */
  54. 'primary-color': '#1890FF',
  55. 'link-color': '#1890FF',
  56. 'border-radius-base': '4px',
  57. },
  58. javascriptEnabled: true,
  59. }
  60. }
  61. },
  62. devServer: {
  63. proxy: {
  64. // '/api': {
  65. // target: 'https://mock.ihx.me/mock/5baf3052f7da7e07e04a5116/antd-pro', //mock API接口系统
  66. // ws: false,
  67. // changeOrigin: true,
  68. // pathRewrite: {
  69. // '/jeecg-boot': '' //默认所有请求都加了jeecg-boot前缀,需要去掉
  70. // }
  71. // },
  72. '/jeecg-boot': {
  73. target: 'http://39.97.241.236:8080/jeecg-boot/', //请求本地 需要jeecg-boot后台项目
  74. ws: false,
  75. changeOrigin: true,
  76. pathRewrite: {
  77. '^/': '/'
  78. }
  79. },
  80. }
  81. },
  82. lintOnSave: undefined
  83. }