vite-px-to-vw
v1.0.5
Published
A Vite plugin for converting px to vw
Maintainers
Readme
vite-px-to-vw
A Vite plugin for converting px units to vw units in Nuxt 3 projects, including handling SVGs without explicit width and height.
Installation
Usage
Add the plugin to your nuxt.config.ts file or vite.config.ts file:
import { defineNuxtConfig } from 'nuxt/config';
import PxToVwPlugin from 'vite-px-to-vw';
export default defineNuxtConfig({
build: {
transpile: ['your-package-name'], // If needed
},
css: [
// Your global styles
],
vite: {
plugins: [
PxToVwPlugin({
viewportWidth: 375, // 设计稿宽度,默认375px
unitPrecision: 5, // 转换后的小数点精度
mediaQuery: false, // 是否转换媒体查询中的px
minPixelValue: 1, // 最小像素值,小于该值不会被转换
exclude: [], // 排除某些文件或文件夹
}),
],
},
});