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.

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