vue.config.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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://web-jytest.jydev.jianyu360.com',
  42. // target: 'http://192.168.20.178:8800',
  43. changeOrigin: true,
  44. logLevel: 'debug',
  45. pathRewrite: {
  46. '^/bigmember': '/bigmember'
  47. }
  48. },
  49. '^/jypay': {
  50. target: 'https://web-jytest.jydev.jianyu360.com',
  51. changeOrigin: true,
  52. logLevel: 'debug'
  53. },
  54. '^/publicapply': {
  55. target: 'http://192.168.20.241:828',
  56. changeOrigin: true,
  57. logLevel: 'debug'
  58. }
  59. }
  60. },
  61. css: {
  62. loaderOptions: {
  63. sass: {
  64. prependData: '@import "@/assets/style/_mixin.scss";@import "@/assets/style/_variables.scss";'
  65. }
  66. }
  67. },
  68. chainWebpack: config => {
  69. // single-spa
  70. if (!process.env.VUE_APP_ALONE) {
  71. config.devServer.set('inline', false)
  72. config.devServer.set('hot', true)
  73. if (process.env.NODE_ENV === 'production') {
  74. config.externals([
  75. 'vue',
  76. 'vue-router',
  77. 'vuex',
  78. 'axios',
  79. 'lodash',
  80. 'moment'
  81. ])
  82. config.plugin('html').tap(args => {
  83. // html中添加cdn
  84. args[0].cdn = cdn
  85. return args
  86. })
  87. } else {
  88. config.output.filename('js/[name].js')
  89. }
  90. }
  91. // 分析静态资源
  92. if (process.env.use_analyzer) {
  93. config
  94. .plugin('webpack-bundle-analyzer')
  95. .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin)
  96. }
  97. },
  98. filenameHashing: false
  99. }