Skip to content

Instantly share code, notes, and snippets.

@Posandu
Created July 6, 2022 11:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Posandu/facad656e5bef48a1129585c8553ac52 to your computer and use it in GitHub Desktop.
Save Posandu/facad656e5bef48a1129585c8553ac52 to your computer and use it in GitHub Desktop.
Stylify config for React-vite
import { defineConfig } from "vite";
import { vitePlugin } from "@stylify/unplugin";
import react from "@vitejs/plugin-react";
const stylifyPlugin = vitePlugin({
transformIncludeFilter: (id) =>
id.endsWith("js") ||
id.endsWith("ts") ||
id.endsWith("tsx") ||
id.endsWith("jsx"),
bundles: [
{
outputFile: "./src/styles/stylify.css",
files: ["./src/*.js", "./src/*.ts", "./src/*.jsx", "./src/*.tsx"],
},
],
extend: {
bundler: {
compiler: {
selectorsAreas: [
'(?:^|\\s+)className="([^"]+)"',
"(?:^|\\s+)className='([^']+)'",
"(?:^|\\s+)className=\\{`((?:.|\n)+)`\\}",
],
},
},
},
});
// https://vitejs.dev/config/
export default defineConfig({
plugins: [stylifyPlugin, react()],
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment