vue.config.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. publicPath: '/backStage/',
  11. outputDir: process.env.outputDir,
  12. // assetsPublicPath: '/vuefiv/',
  13. // assetsDir: 'vuefiv',
  14. // * 分别为生成环境和开发环境配置
  15. configureWebpack: config => {
  16. if (process.env.NODE_ENV === 'production') {
  17. // 为生产环境修改配置...
  18. config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
  19. } else {
  20. // 为开发环境修改配置...
  21. }
  22. Object.assign(config, {
  23. externals: {
  24. 'AMap': 'AMap',
  25. 'AMapUI': 'AMapUI'
  26. },
  27. resolve: {
  28. extensions: ['.js', '.vue', '.json'],
  29. alias: {
  30. '@': resolve('src'),
  31. '~': process.cwd(),
  32. public: resolve('public'),
  33. components: resolve('src/components'),
  34. util: resolve('src/utils'),
  35. store: resolve('src/store'),
  36. router: resolve('src/router')
  37. }
  38. },
  39. })
  40. },
  41. devServer: {
  42. hot: true, //自动保存
  43. proxy: {
  44. // '/vuefiv/': {
  45. './backStage/': {
  46. target: 'https://qhome.usky.cn/fivapi',
  47. ws: false,
  48. changeOrigin: true,
  49. pathRewrite: {
  50. '^./': './'
  51. }
  52. }
  53. },
  54. public: 'localhost:8080/backStage/'
  55. }
  56. }