vue.config.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. const { defineConfig } = require('@vue/cli-service')
  2. module.exports = defineConfig({
  3. transpileDependencies: true,
  4. devServer: {
  5. host: '0.0.0.0', //可以忽略不写
  6. port: 8101, //它是用来修改你打开后的端口号的
  7. open: true, //值为 true的话,项目启动时自动打开到浏览器里边, false不会打开
  8. proxy: {
  9. ['/api/als']: {
  10. target: 'http://localhost:9090',
  11. ws: false, //也可以忽略不写,不写不会影响跨域
  12. changeOrigin: true, //是否开启跨域,值为 true 就是开启, false 不开启
  13. pathRewrite: {
  14. ['^' + '/api/als']: '/als'
  15. }
  16. },
  17. [process.env.VUE_APP_BASE_API]: {
  18. target: process.env.VUE_APP_BASE_API_target,
  19. ws: false, //也可以忽略不写,不写不会影响跨域
  20. changeOrigin: true, //是否开启跨域,值为 true 就是开启, false 不开启
  21. pathRewrite: {
  22. ['^' + process.env.VUE_APP_BASE_API]: ''
  23. }
  24. }
  25. }
  26. },
  27. //全局 sass的配置
  28. chainWebpack(config) {
  29. globalSass(config)
  30. }
  31. })
  32. /**
  33. * 注意Dependencies需要引入
  34. * "sass": "^1.32.7",
  35. *"sass-loader": "^12.0.0",
  36. *"sass-resources-loader": "^2.2.5"
  37. * 全局变量的Sass引方法
  38. * @param config chainWebpack(config) 中来的一个配置
  39. */
  40. const globalSass = (config) => {
  41. const oneOfsMap = config.module.rule('scss').oneOfs.store
  42. oneOfsMap.forEach((item) => {
  43. item
  44. .use('sass-resources-loader')
  45. .loader('sass-resources-loader')
  46. .options({
  47. resources: './src/style/index.scss' //相对路径
  48. })
  49. .end()
  50. })
  51. }