Skip to content

Instantly share code, notes, and snippets.

@Anush008
Anush008 / gist:ffebc6ceb5439dc1ca2996ff7fb88311
Created July 25, 2023 17:13
Vite classname prefixer plugin
export default function classnamePrefixPlugin() {
const prefix = "tw-";
return {
name: "classname-prefix",
transform: (code, id) => {
let classNamePattern = /(className|class)\s*(:|=)\s*"([^"]*)"/g;
const transformedCode = code.replace(
classNamePattern,
(match, p1, p2, p3) => {