vue.config.js 2.0 KB

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