vue.config.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. const path = require('path');
  2. const publics = path.resolve(__dirname, '../web-common');
  3. module.exports = {
  4. publicPath: process.env.NODE_ENV === 'development' ? '/' : 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. '@publics': publics,
  14. },
  15. },
  16. });
  17. },
  18. devServer: {
  19. port: '8001',
  20. //api地址前缀
  21. proxy: {
  22. '/weixin': {
  23. target: 'http://smart.cc-lotus.info',
  24. changeOrigin: true,
  25. ws: true,
  26. },
  27. '/files': {
  28. target: 'http://free.liaoningdoupo.com',
  29. },
  30. '/api': {
  31. target: 'http://free.liaoningdoupo.com',
  32. changeOrigin: true,
  33. ws: true,
  34. },
  35. '/ws': {
  36. target: 'http://free.liaoningdoupo.com',
  37. ws: true,
  38. },
  39. },
  40. },
  41. chainWebpack: config => {
  42. const types = ['vue-modules', 'vue', 'normal-modules', 'normal'];
  43. types.forEach(type => addStyleResource(config.module.rule('less').oneOf(type)));
  44. },
  45. };
  46. function addStyleResource(rule) {
  47. rule
  48. .use('style-resource')
  49. .loader('style-resources-loader')
  50. .options({
  51. patterns: [
  52. path.resolve(__dirname, './src/style/color.less'), // 需要全局导入的less
  53. ],
  54. });
  55. }