vue.config.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. const path = require('path')
  2. function resolve(dir) {
  3. return path.join(__dirname, dir);
  4. }
  5. // 基本结构
  6. module.exports = {
  7. // 打包后路径错误导致的空白页面问题。
  8. // publicPath: '/vuefiv/',
  9. publicPath: '/panel/',
  10. outputDir: process.env.outputDir,
  11. // assetsPublicPath: '/vuefiv/',
  12. // assetsDir: 'vuefiv',
  13. // * 分别为生成环境和开发环境配置
  14. configureWebpack: config => {
  15. if (process.env.NODE_ENV === 'production') {
  16. // 为生产环境修改配置...
  17. config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
  18. } else {
  19. // 为开发环境修改配置...
  20. }
  21. Object.assign(config, {
  22. externals: {
  23. 'AMap': 'AMap',
  24. 'AMapUI': 'AMapUI'
  25. },
  26. resolve: {
  27. extensions: ['.js', '.vue', '.json'],
  28. alias: {
  29. '@': resolve('src'),
  30. '~': process.cwd(),
  31. public: resolve('public'),
  32. components: resolve('src/components'),
  33. util: resolve('src/utils'),
  34. store: resolve('src/store'),
  35. router: resolve('src/router')
  36. }
  37. },
  38. })
  39. },
  40. devServer: {
  41. proxy: {
  42. // '/vuefiv/': {
  43. './': {
  44. target: 'https://qhome.usky.cn/fivapi',
  45. ws: false,
  46. changeOrigin: true,
  47. pathRewrite: {
  48. '^./': './'
  49. }
  50. }
  51. },
  52. public: 'localhost:8080/vuefiv/'
  53. }
  54. }