Skip to content

penjj/lightningcss-plugin-px-to-viewport

Repository files navigation

lightningcss-plugin-px-to-viewport

Usage

// using with vite

import { defineConfig } from "vite";
import { composeVisitors } from "lightningcss";
import createPxToVwVisitor from "lightningcss-plugin-px-to-viewport";

export default defineConfig({
  css: {
    transform: "lightningcss",
    lightningcss: {
      visitor: composeVisitors([
        createPxToVwVisitor({
          designWidth: 320,
          minPixelValue: 1,
          excludeSelectors: [{ type: 'class', name: /^mui-/ }] // exclude `.mui-*` class
        }),
      ]),
    } as any,
  },
});