vue.config.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. const path = require('path');
  2. // const webpack = require('webpack');
  3. const StyleLintPlugin = require('stylelint-webpack-plugin');
  4. const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
  5. module.exports = {
  6. devServer: {
  7. proxy: {
  8. '/api': {
  9. target: 'https://www.example.com',
  10. changeOrigin: true,
  11. pathRewrite: {
  12. '/api': '',
  13. },
  14. },
  15. },
  16. },
  17. publicPath: '',
  18. chainWebpack: config => {
  19. // 自动导入 resources.less 文件
  20. const types = ['vue-modules', 'vue', 'normal-modules', 'normal'];
  21. types.forEach(type => {
  22. config.module
  23. .rule('less')
  24. .oneOf(type)
  25. .use('style-resource')
  26. .loader('style-resources-loader')
  27. .options({
  28. patterns: [path.resolve(__dirname, './src/assets/styles/resources.less')],
  29. });
  30. });
  31. config
  32. .plugin('style-lint')
  33. .use(StyleLintPlugin, [
  34. {
  35. files: ['src/**/*.{vue,html,css,less,scss,sass}'],
  36. },
  37. ]);
  38. if (process.nev === 'production') {
  39. config.plugin('bundle-analyzer').use(BundleAnalyzerPlugin);
  40. }
  41. },
  42. };