vue.config.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. hot: true, //自动保存
  42. proxy: {
  43. // '/vuefiv/': {
  44. './': {
  45. target: 'https://qhome.usky.cn/fivapi',
  46. ws: false,
  47. changeOrigin: true,
  48. pathRewrite: {
  49. '^./': './'
  50. }
  51. }
  52. },
  53. public: 'localhost:8080/vuefiv/'
  54. }
  55. }