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.

91 lines
2.7 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
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 { chunkSplitPlugin } from 'vite-plugin-chunk-split'
  7. import viteImagemin from 'vite-plugin-imagemin'
  8. // https://vitejs.dev/config/
  9. export default defineConfig({
  10. resolve: {
  11. alias: {
  12. '@': resolve(__dirname, 'src'),
  13. cpns: resolve(__dirname, 'src/components'),
  14. },
  15. extensions: ['.js', '.json', '.vue'],
  16. },
  17. assetsInclude: ['**/*.m4v', '**/*.mp4'],
  18. server: {
  19. host: '0.0.0.0',
  20. },
  21. plugins: [
  22. vue(),
  23. chunkSplitPlugin(),
  24. // viteImagemin({
  25. // gifsicle: {
  26. // optimizationLevel: 7,
  27. // interlaced: false,
  28. // },
  29. // optipng: {
  30. // optimizationLevel: 7,
  31. // },
  32. // mozjpeg: {
  33. // quality: 20,
  34. // },
  35. // pngquant: {
  36. // quality: [0.8, 0.9],
  37. // speed: 4,
  38. // },
  39. // svgo: {
  40. // plugins: [
  41. // {
  42. // name: 'removeViewBox',
  43. // },
  44. // {
  45. // name: 'removeEmptyAttrs',
  46. // active: false,
  47. // },
  48. // ],
  49. // },
  50. // }),
  51. ],
  52. //配置sass
  53. css: {
  54. preprocessorOptions: {
  55. scss: {
  56. additionalData:
  57. '@import "./src/assets/scss/globalVar.scss";@import "./src/assets/scss/globalMixin.scss";',
  58. },
  59. },
  60. postcss: {
  61. plugins: [
  62. autoprefixer({
  63. overrideBrowserslist: [
  64. 'Android 4.1',
  65. 'iOS 7.1',
  66. 'Chrome > 31',
  67. 'ff > 31',
  68. 'ie >= 8',
  69. ],
  70. }),
  71. postcsspxtoviewport({
  72. unitToConvert: 'px', // 要转化的单位
  73. viewportWidth: 1920, // UI设计稿的宽度
  74. viewportHeight: 1080, // UI设计稿高度
  75. unitPrecision: 6, // 转换后的精度,即小数点位数
  76. propList: ['*'], // 指定转换的css属性的单位,*代表全部css属性的单位都进行转换
  77. viewportUnit: 'vw', // 指定需要转换成的视窗单位,默认vw
  78. fontViewportUnit: 'vw', // 指定字体需要转换成的视窗单位,默认vw
  79. selectorBlackList: ['ignore-'], // 指定不转换为视窗单位的类名,
  80. minPixelValue: 1, // 默认值1,小于或等于1px则不进行转换
  81. mediaQuery: true, // 是否在媒体查询的css代码中也进行转换,默认false
  82. replace: true, // 是否转换后直接更换属性值
  83. // exclude: [/node_modules/], // 设置忽略文件,用正则做目录名匹配
  84. exclude: [],
  85. landscape: false, // 是否处理横屏情况
  86. }),
  87. ],
  88. },
  89. },
  90. })