vue.config.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. const { defineConfig } = require('@vue/cli-service')
  2. const cdn = {
  3. css: [
  4. // '//unpkg.com/element-ui@2.10.1/lib/theme-chalk/index.css'
  5. ],
  6. js: [
  7. '//cdn-common.jianyu360.com/cdn/lib/vue/2.6.14/vue.runtime.min.js',
  8. '//cdn-common.jianyu360.com/cdn/lib/vue-router/3.1.5/vue-router.min.js',
  9. '//cdn-common.jianyu360.com/cdn/lib/vuex/3.4.0/vuex.min.js',
  10. '//cdn-common.jianyu360.com/cdn/lib/axios/0.19.2/axios.min.js',
  11. '//cdn-common.jianyu360.com/cdn/lib/js-cookie/2.2.1/js.cookie.min.js',
  12. '//cdn-common.jianyu360.com/cdn/lib/moment/2.29.1/min/moment.min.js',
  13. ]
  14. }
  15. const externals = {
  16. vue: 'Vue',
  17. 'vue-router': 'VueRouter',
  18. vuex: 'Vuex',
  19. axios: 'axios',
  20. 'js-cookie': 'Cookies',
  21. moment: 'moment'
  22. }
  23. module.exports = defineConfig({
  24. publicPath: process.env.VUE_APP_BASE_URL,
  25. outputDir: 'page_pc_stationSocial',
  26. transpileDependencies: true,
  27. lintOnSave: true,
  28. productionSourceMap: false,
  29. devServer: {
  30. port: '8080',
  31. open: false,
  32. client: {
  33. overlay: {
  34. errors: true,
  35. warnings: false
  36. }
  37. },
  38. historyApiFallback: true,
  39. proxy: {
  40. '^/api/userCenter': {
  41. target: 'http://192.168.3.240:8077',
  42. changeOrigin: true,
  43. logLevel: 'debug',
  44. pathRewrite: {
  45. '^/api': ''
  46. }
  47. },
  48. '^/api/orderApplication': {
  49. target: 'http://192.168.21.175:9999',
  50. changeOrigin: true,
  51. logLevel: 'debug',
  52. pathRewrite: {
  53. '^/api': ''
  54. }
  55. },
  56. '^/api': {
  57. target: 'http://192.168.3.128:8077',
  58. changeOrigin: true,
  59. logLevel: 'debug',
  60. pathRewrite: {
  61. '^/api': ''
  62. }
  63. }
  64. }
  65. },
  66. css: {
  67. loaderOptions: {
  68. sass: {
  69. additionalData: '@import "@/assets/style/_mixin.scss";@import "@/assets/style/_variables.scss";'
  70. }
  71. }
  72. },
  73. chainWebpack: config => {
  74. if (process.env.NODE_ENV === 'production') {
  75. // 生产环境配置
  76. config.externals(externals)
  77. config.plugin('html').tap(args => {
  78. // html中添加cdn
  79. args[0].cdn = cdn
  80. return args
  81. })
  82. config.optimization.minimize(true)
  83. .minimizer('terser')
  84. .tap(args => {
  85. const { terserOptions } = args[0]
  86. terserOptions.compress.drop_console = true
  87. terserOptions.compress.drop_debugger = true
  88. return args
  89. })
  90. }
  91. }
  92. })