vue.config.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. const path = require('path');
  2. function resolve(dir) {
  3. return path.join(__dirname, '.', dir);
  4. }
  5. module.exports = {
  6. publicPath: '/',
  7. assetsDir: 'static',
  8. productionSourceMap: false,
  9. // webpack-dev-server 相关配置
  10. devServer: {
  11. host: '0.0.0.0',
  12. port: 80,
  13. proxy: {
  14. [process.env.VUE_APP_BASE_API]: {
  15. //后端服务地址和端口
  16. target: 'http://localhost:8081',
  17. //是否跨域
  18. changeOrigin: true,
  19. pathRewrite: {
  20. ['^' + process.env.VUE_APP_BASE_API]: ''
  21. }
  22. }
  23. },
  24. disableHostCheck: true
  25. },
  26. chainWebpack: config => {
  27. config.module
  28. .rule('svg')
  29. .exclude.add(resolve('src/assets/icons'))
  30. .end();
  31. config.module
  32. .rule('icons')
  33. .test(/\.svg$/)
  34. .include.add(resolve('src/assets/icons'))
  35. .end()
  36. .use('svg-sprite-loader')
  37. .loader('svg-sprite-loader')
  38. .options({
  39. symbolId: 'icon-[name]'
  40. });
  41. }
  42. }