hjyd
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.

57 lines
1.9 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. import { defineConfig } from 'vite'
  2. import { resolve } from 'path'
  3. import vue from '@vitejs/plugin-vue'
  4. import autoprefixer from 'autoprefixer'
  5. import postcsspxtoviewport from 'postcss-px-to-viewport'
  6. // https://vitejs.dev/config/
  7. export default defineConfig({
  8. resolve: {
  9. alias: {
  10. '@': resolve(__dirname, 'src'),
  11. cpns: resolve(__dirname, 'src/components'),
  12. },
  13. extensions: ['.js', '.json', '.vue'],
  14. },
  15. server: {
  16. host: '0.0.0.0',
  17. },
  18. plugins: [vue()],
  19. //配置sass
  20. css: {
  21. preprocessorOptions: {
  22. scss: {
  23. additionalData:
  24. '@import "./src/assets/scss/globalVar.scss";@import "./src/assets/scss/globalMixin.scss";',
  25. },
  26. },
  27. postcss: {
  28. plugins: [
  29. autoprefixer({
  30. overrideBrowserslist: [
  31. 'Android 4.1',
  32. 'iOS 7.1',
  33. 'Chrome > 31',
  34. 'ff > 31',
  35. 'ie >= 8',
  36. ],
  37. }),
  38. postcsspxtoviewport({
  39. unitToConvert: 'px', // 要转化的单位
  40. viewportWidth: 1920, // UI设计稿的宽度
  41. unitPrecision: 6, // 转换后的精度,即小数点位数
  42. propList: ['*'], // 指定转换的css属性的单位,*代表全部css属性的单位都进行转换
  43. viewportUnit: 'vw', // 指定需要转换成的视窗单位,默认vw
  44. fontViewportUnit: 'vw', // 指定字体需要转换成的视窗单位,默认vw
  45. selectorBlackList: ['ignore-'], // 指定不转换为视窗单位的类名,
  46. minPixelValue: 1, // 默认值1,小于或等于1px则不进行转换
  47. mediaQuery: true, // 是否在媒体查询的css代码中也进行转换,默认false
  48. replace: true, // 是否转换后直接更换属性值
  49. // exclude: [/node_modules/], // 设置忽略文件,用正则做目录名匹配
  50. exclude: [],
  51. landscape: false, // 是否处理横屏情况
  52. }),
  53. ],
  54. },
  55. },
  56. })