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.

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