vue.config.js 1.4 KB

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