vue.config.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. const path = require('path')
  2. const webpack = require('webpack')
  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. /*
  14. pages: {
  15. index: {
  16. entry: 'src/main.js',
  17. chunks: ['chunk-vendors', 'chunk-common', 'index']
  18. }
  19. },
  20. */
  21. configureWebpack: {
  22. plugins: [
  23. // Ignore all locale files of moment.js
  24. new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
  25. ]
  26. },
  27. chainWebpack: (config) => {
  28. config.resolve.alias
  29. .set('@$', resolve('src'))
  30. .set('@api', resolve('src/api'))
  31. .set('@assets', resolve('src/assets'))
  32. .set('@comp', resolve('src/components'))
  33. .set('@views', resolve('src/views'))
  34. .set('@layout', resolve('src/layout'))
  35. .set('@static', resolve('src/static'))
  36. const svgRule = config.module.rule('svg')
  37. svgRule.uses.clear()
  38. svgRule.use('vue-svg-loader')
  39. .loader('vue-svg-loader')
  40. },
  41. css: {
  42. loaderOptions: {
  43. less: {
  44. modifyVars: {
  45. /* less 变量覆盖,用于自定义 ant design 主题 */
  46. /*
  47. 'primary-color': '#F5222D',
  48. 'link-color': '#F5222D',
  49. 'border-radius-base': '4px',
  50. */
  51. },
  52. javascriptEnabled: true
  53. }
  54. }
  55. },
  56. devServer: {
  57. proxy: {
  58. '/api': {
  59. // target: 'https://mock.ihx.me/mock/5baf3052f7da7e07e04a5116/antd-pro',
  60. target: 'https://mock.ihx.me/mock/5baf3052f7da7e07e04a5116/antd-pro',
  61. ws: false,
  62. changeOrigin: true
  63. },
  64. '/gateway': {
  65. target: 'https://www.easy-mock.com/mock/5b7bce071f130e5b7fe8cd7d/antd-pro',
  66. ws: false,
  67. changeOrigin: true,
  68. pathRewrite: {
  69. '^/gateway': '/api'
  70. }
  71. }
  72. }
  73. },
  74. lintOnSave: undefined
  75. }