You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

61 line
1.6 KiB

  1. const path = require('path');
  2. const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
  3. // require('vue-cli-plugin-style-resources-loader')
  4. function resolve(dir) {
  5. return path.join(__dirname, dir)
  6. }
  7. module.exports = {
  8. devServer: {
  9. // open: true, // 是否自动打开浏览器页面
  10. // host: 'localhost', // 指定使用一个 host,默认是 localhost
  11. port: 8090, // 端口地址
  12. proxy: {
  13. '/fumaoA': {
  14. target: 'https://admintest.malls.iformall.com/api',
  15. changeOrigin: true,
  16. pathRewrite: {
  17. '^/fumaoA': ''
  18. }
  19. },
  20. '/fumao': {
  21. target: 'https://btest.malls.iformall.com/B',
  22. changeOrigin: true,
  23. pathRewrite: {
  24. '^/fumao': ''
  25. }
  26. },
  27. }
  28. },
  29. publicPath: './', // 打包后引用的资源路径
  30. // outputDir: 'dist', // 打包目录
  31. configureWebpack: (config) => { // webpack自定义配置
  32. // 生产环境打包分析体积
  33. if (process.env.NODE_ENV === 'production' && process.env.npm_config_report) {
  34. return {
  35. plugins: [
  36. new BundleAnalyzerPlugin()
  37. ]
  38. }
  39. }
  40. },
  41. chainWebpack: config => { // CLI内部webpack配置
  42. const types = ['vue-modules', 'vue', 'normal-modules', 'normal']
  43. types.forEach(type => addStyleResource(config.module.rule('less').oneOf(type)))
  44. },
  45. }
  46. // 全局样式 变量、函数
  47. function addStyleResource (rule) {
  48. rule.use('style-resource')
  49. .loader('style-resources-loader')
  50. .options({
  51. patterns: [
  52. resolve('src/styles/variables.less'),
  53. resolve('src/styles/mixin.less'),
  54. ],
  55. })
  56. }