vue.config.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. const path = require('path');
  2. module.exports = {
  3. publicPath: process.env.NODE_ENV === 'development' ? '/' : '/' + process.env.VUE_APP_ROUTER,
  4. outputDir: process.env.VUE_APP_ROUTER,
  5. configureWebpack: config => {
  6. Object.assign(config, {
  7. // 开发生产共同配置
  8. resolve: {
  9. alias: {
  10. '@': path.resolve(__dirname, './src'),
  11. '@c': path.resolve(__dirname, './src/components'),
  12. '@a': path.resolve(__dirname, './src/assets'),
  13. },
  14. },
  15. });
  16. },
  17. devServer: {
  18. port: '8001',
  19. //api地址前缀
  20. proxy: {
  21. '/weixin': {
  22. target: 'http://smart.cc-lotus.info',
  23. changeOrigin: true,
  24. ws: true,
  25. },
  26. '/files': {
  27. target: 'http://broadcast.waityou24.cn/',
  28. },
  29. '/api': {
  30. target: 'http://127.0.0.1:3001',
  31. changeOrigin: true,
  32. ws: true,
  33. },
  34. '/ws': {
  35. target: 'http://broadcast.waityou24.cn/',
  36. ws: true,
  37. },
  38. },
  39. },
  40. chainWebpack: config => {
  41. const types = ['vue-modules', 'vue', 'normal-modules', 'normal'];
  42. types.forEach(type => addStyleResource(config.module.rule('less').oneOf(type)));
  43. },
  44. };
  45. function addStyleResource(rule) {
  46. rule
  47. .use('style-resource')
  48. .loader('style-resources-loader')
  49. .options({
  50. patterns: [
  51. path.resolve(__dirname, './src/style/color.less'), // 需要全局导入的less
  52. ],
  53. });
  54. }