vue.config.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. publicPath: './',
  22. configureWebpack: {
  23. plugins: [
  24. // Ignore all locale files of moment.js
  25. new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
  26. ]
  27. },
  28. chainWebpack: (config) => {
  29. config.plugin('copy').tap((args) => [[
  30. {
  31. from: './public',
  32. to: './',
  33. toType: 'dir',
  34. ignore: [
  35. 'config.js'
  36. ]
  37. }
  38. ]])
  39. config.resolve.alias
  40. .set('@$', resolve('src'))
  41. .set('@api', resolve('src/api'))
  42. .set('@assets', resolve('src/assets'))
  43. .set('@comp', resolve('src/components'))
  44. .set('@views', resolve('src/views'))
  45. .set('@layout', resolve('src/layout'))
  46. .set('@static', resolve('src/static'))
  47. const svgRule = config.module.rule('svg')
  48. svgRule.uses.clear()
  49. svgRule
  50. .oneOf('inline')
  51. .resourceQuery(/inline/)
  52. .use('vue-svg-icon-loader')
  53. .loader('vue-svg-icon-loader')
  54. .end()
  55. .end()
  56. .oneOf('external')
  57. .use('file-loader')
  58. .loader('file-loader')
  59. .options({
  60. name: 'assets/[name].[hash:8].[ext]'
  61. })
  62. /* svgRule.oneOf('inline')
  63. .resourceQuery(/inline/)
  64. .use('vue-svg-loader')
  65. .loader('vue-svg-loader')
  66. .end()
  67. .end()
  68. .oneOf('external')
  69. .use('file-loader')
  70. .loader('file-loader')
  71. .options({
  72. name: 'assets/[name].[hash:8].[ext]'
  73. })
  74. */
  75. },
  76. css: {
  77. loaderOptions: {
  78. less: {
  79. modifyVars: {
  80. /* less 变量覆盖,用于自定义 ant design 主题 */
  81. /*
  82. 'primary-color': '#F5222D',
  83. 'link-color': '#F5222D',
  84. 'border-radius-base': '4px',
  85. */
  86. },
  87. javascriptEnabled: true
  88. }
  89. }
  90. },
  91. devServer: {
  92. // development server port 8000
  93. port: 8000,
  94. proxy: {
  95. '/api': {
  96. // target: 'https://mock.ihx.me/mock/5baf3052f7da7e07e04a5116/antd-pro',
  97. target: 'https://pwxdev.cleartv.cn/',
  98. ws: false,
  99. changeOrigin: true,
  100. pathRewrite: {
  101. '^/api': ''
  102. }
  103. }
  104. }
  105. },
  106. // disable source map in production
  107. productionSourceMap: false,
  108. lintOnSave: undefined,
  109. // babel-loader no-ignore node_modules/*
  110. transpileDependencies: []
  111. }