vue.config.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. const cdn = {
  2. css: [
  3. // '//unpkg.com/element-ui@2.10.1/lib/theme-chalk/index.css'
  4. ],
  5. jsdelivr: [
  6. '//cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.min.js',
  7. '//cdn.jsdelivr.net/npm/vue-router@3.1.5/dist/vue-router.min.js',
  8. '//cdn.jsdelivr.net/npm/vuex@3.4.0/dist/vuex.min.js',
  9. '//cdn.jsdelivr.net/npm/axios@0.19.2/dist/axios.min.js',
  10. '//cdn.jsdelivr.net/npm/echarts@4.8.0/dist/echarts.min.js',
  11. '//cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js',
  12. '//cdn.jsdelivr.net/npm/moment@2.29.1/moment.min.js'
  13. ],
  14. js: [
  15. '//cdn-common.jianyu360.cn/cdn/lib/vue/2.6.11/vue.min.js',
  16. '//cdn-common.jianyu360.cn/cdn/lib/vue-router/3.1.5/vue-router.min.js',
  17. '//cdn-common.jianyu360.cn/cdn/lib/vuex/3.4.0/vuex.min.js',
  18. '//cdn-common.jianyu360.cn/cdn/lib/axios/0.19.2/axios.min.js',
  19. '//cdn-common.jianyu360.cn/cdn/lib/echarts/4.8.0/echarts.min.js',
  20. '//cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js',
  21. '//cdn.jsdelivr.net/npm/moment@2.29.1/moment.min.js'
  22. ]
  23. }
  24. module.exports = {
  25. parallel: false,
  26. productionSourceMap: false,
  27. outputDir: 'page_big_pc',
  28. publicPath: process.env.VUE_APP_BASE_PUBLIC,
  29. lintOnSave: true,
  30. devServer: {
  31. port: '8080',
  32. disableHostCheck: true,
  33. proxy: {
  34. // 反爬虫接口代理
  35. // '/subVipPortrait/winner': {
  36. // target: 'http://192.168.20.178:8800',
  37. // changeOrigin: true,
  38. // logLevel: 'debug'
  39. // },
  40. '^/bigmember': {
  41. // target: 'https://web2-jytest.jydev.jianyu360.com',
  42. target: 'http://127.0.0.1:814',
  43. changeOrigin: true,
  44. logLevel: 'debug',
  45. pathRewrite: {
  46. '^/bigmember': '/bigmember'
  47. }
  48. },
  49. '^/jypay': {
  50. target: 'https://web2-jytest.jydev.jianyu360.com',
  51. changeOrigin: true,
  52. logLevel: 'debug'
  53. },
  54. '^/publicapply': {
  55. // target: 'https://web2-jytest.jydev.jianyu360.com',
  56. target: 'http://127.0.0.1:828',
  57. changeOrigin: true,
  58. logLevel: 'debug'
  59. },
  60. '^/salesLeads': {
  61. // target: 'https://web2-jytest.jydev.jianyu360.com',
  62. target: 'http://127.0.0.1:8881',
  63. changeOrigin: true,
  64. logLevel: 'debug'
  65. }
  66. }
  67. },
  68. css: {
  69. loaderOptions: {
  70. sass: {
  71. prependData: '@import "@/assets/style/_mixin.scss";@import "@/assets/style/_variables.scss";'
  72. }
  73. }
  74. },
  75. chainWebpack: config => {
  76. // single-spa
  77. if (!process.env.VUE_APP_ALONE) {
  78. config.devServer.set('inline', false)
  79. config.devServer.set('hot', true)
  80. if (process.env.NODE_ENV === 'production') {
  81. config.externals([
  82. 'vue',
  83. 'vue-router',
  84. 'vuex',
  85. 'axios',
  86. 'lodash',
  87. 'moment'
  88. ])
  89. config.plugin('html').tap(args => {
  90. // html中添加cdn
  91. args[0].cdn = cdn
  92. return args
  93. })
  94. } else {
  95. config.output.filename('js/[name].js')
  96. }
  97. }
  98. // 分析静态资源
  99. if (process.env.use_analyzer) {
  100. config
  101. .plugin('webpack-bundle-analyzer')
  102. .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin)
  103. }
  104. },
  105. filenameHashing: false
  106. }