vue.config.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const { defineConfig } = require('@vue/cli-service')
  2. const path = require('path')
  3. const postcssPxToRem = require("postcss-pxtorem")
  4. // function resolve(dir) {
  5. // return path.join(__dirname, dir);
  6. // }
  7. module.exports = defineConfig({
  8. publicPath: './',
  9. chainWebpack: config => {
  10. //svg图标加载
  11. config.module
  12. .rule('svg')
  13. .exclude.add(path.join(__dirname, 'src/assets/icons/svg'))
  14. .end()
  15. config.module
  16. .rule('icons')
  17. .test(/\.svg$/)
  18. .include.add(path.join(__dirname, 'src/assets/icons'))
  19. .end()
  20. .use('svg-sprite-loader')
  21. .loader('svg-sprite-loader')
  22. .options({
  23. symbolId: 'icon-[name]'
  24. })
  25. .end()
  26. },
  27. css: {
  28. loaderOptions: {
  29. postcss: {
  30. postcssOptions: {
  31. plugins: [
  32. postcssPxToRem({
  33. rootValue: 16, // 基准值,根据设计稿调整
  34. propList: ['*'], // 需要转换的属性,这里设置为全部
  35. })
  36. ]
  37. }
  38. }
  39. }
  40. }
  41. })