vue.config.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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:9191',
  11. ws: false,
  12. changeOrigin: true,
  13. pathRewrite: {
  14. ['^' + '/api/als']: '/als'
  15. }
  16. },
  17. ['/api/kgqa']: {
  18. // target: 'http://192.168.0.107:7073',
  19. target: 'http://localhost:7074',
  20. ws: false,
  21. changeOrigin: true,
  22. pathRewrite: {
  23. ['^' + '/api/kgqa']: '/kgqa'
  24. }
  25. },
  26. ['/api/knowledge_base']: {
  27. // target: 'http://192.168.0.103:7861',
  28. target: 'http://localhost:7861',
  29. ws: false,
  30. changeOrigin: true,
  31. pathRewrite: {
  32. ['^' + '/api/knowledge_base']: '/knowledge_base'
  33. }
  34. },
  35. [process.env.VUE_APP_BASE_API]: {
  36. target: process.env.VUE_APP_BASE_API_target,
  37. ws: false, //也可以忽略不写,不写不会影响跨域
  38. changeOrigin: true, //是否开启跨域,值为 true 就是开启, false 不开启
  39. pathRewrite: {
  40. ['^' + process.env.VUE_APP_BASE_API]: ''
  41. }
  42. }
  43. }
  44. },
  45. //全局 sass的配置
  46. chainWebpack(config) {
  47. globalSass(config)
  48. }
  49. })
  50. /**
  51. * 注意Dependencies需要引入
  52. * "sass": "^1.32.7",
  53. *"sass-loader": "^12.0.0",
  54. *"sass-resources-loader": "^2.2.5"
  55. * 全局变量的Sass引方法
  56. * @param config chainWebpack(config) 中来的一个配置
  57. */
  58. const globalSass = (config) => {
  59. const oneOfsMap = config.module.rule('scss').oneOfs.store
  60. oneOfsMap.forEach((item) => {
  61. item
  62. .use('sass-resources-loader')
  63. .loader('sass-resources-loader')
  64. .options({
  65. resources: './src/style/index.scss' //相对路径
  66. })
  67. .end()
  68. })
  69. }