vite.config.js 780 Bytes
Newer Older
朱国瑞's avatar
朱国瑞 committed
1 2 3 4
import {
  defineConfig
} from 'vite'
import vue from '@vitejs/plugin-vue'
5
import postcss100vhFix from 'postcss-100vh-fix'
朱国瑞's avatar
朱国瑞 committed
6
import postCssPxToRem from 'postcss-pxtorem'
7

朱国瑞's avatar
朱国瑞 committed
8 9 10 11
const config = require('./config')

// https://vitejs.dev/config/
export default defineConfig({
12
  envDir: "./",
朱国瑞's avatar
朱国瑞 committed
13
  outDir: config.outDir,
朱国瑞's avatar
朱国瑞 committed
14
  plugins: [vue()],
15 16 17 18
  css: {
    postcss: {
      plugins: [
        postcss100vhFix,
朱国瑞's avatar
朱国瑞 committed
19 20 21 22 23 24
        postCssPxToRem({
          rootValue: 37.5, // 1rem 的大小
          propList: ['*'], // 需要转换的属性,*(全部转换)
          selectorBlackList: ['pc'],
          unitPrecision: 6 // 转换精度,保留的小数位数
        })
25 26 27
      ]
    }
  },
朱国瑞's avatar
朱国瑞 committed
28 29 30 31 32 33 34
  base: config.base,
  resolve: config.resolve,
  server: {
    proxy: config.proxy,
    port: config.port
  },
})