vue.config.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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.oneOf('inline')
  39. .resourceQuery(/inline/)
  40. .use('vue-svg-loader')
  41. .loader('vue-svg-loader')
  42. .end()
  43. .end()
  44. .oneOf('external')
  45. .use('file-loader')
  46. .loader('file-loader')
  47. .options({
  48. name: 'assets/[name].[hash:8].[ext]'
  49. })
  50. },
  51. css: {
  52. loaderOptions: {
  53. less: {
  54. modifyVars: {
  55. /* less 变量覆盖,用于自定义 ant design 主题 */
  56. /*
  57. 'primary-color': '#F5222D',
  58. 'link-color': '#F5222D',
  59. 'border-radius-base': '4px',
  60. */
  61. },
  62. javascriptEnabled: true
  63. }
  64. }
  65. },
  66. devServer: {
  67. proxy: {
  68. '/api': {
  69. // target: 'https://mock.ihx.me/mock/5baf3052f7da7e07e04a5116/antd-pro',
  70. target: 'https://mock.ihx.me/mock/5baf3052f7da7e07e04a5116/antd-pro',
  71. ws: false,
  72. changeOrigin: true
  73. },
  74. '/gateway': {
  75. target: 'https://www.easy-mock.com/mock/5b7bce071f130e5b7fe8cd7d/antd-pro',
  76. ws: false,
  77. changeOrigin: true,
  78. pathRewrite: {
  79. '^/gateway': '/api'
  80. }
  81. }
  82. }
  83. },
  84. lintOnSave: undefined
  85. }