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.

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