Skip to content

Commit

Permalink
Add option for CSS layer output (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathpaiement authored Sep 27, 2024
1 parent d084af2 commit 8583330
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/vite-plugin-stylex/src/main.mts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ interface StyleXVitePluginOptions
* @default ["@stylexjs/open-props"]
*/
libraries?: string[];

/**
* Whether to use CSS layers for StyleX styles.
*
* @default true
*/
useCSSLayers?: boolean;
}

const STYLEX_REPLACE_RULE = "@stylex stylesheet;";
Expand All @@ -76,6 +83,7 @@ export default function styleXVitePlugin({
unstable_moduleResolution = { type: "commonJS", rootDir: process.cwd() },
stylexImports = ["@stylexjs/stylex"],
libraries: inputLibraries = [],
useCSSLayers = true,
...options
}: Omit<StyleXVitePluginOptions, "dev" | "fileName"> = {}) {
const libraries = ["@stylexjs/open-props", ...inputLibraries];
Expand Down Expand Up @@ -128,7 +136,7 @@ export default function styleXVitePlugin({
// @ts-ignore
const stylexCSS = stylexBabelPlugin.processStylexRules(
rules.filter(Boolean),
true
useCSSLayers
) as string;

lastStyleXCSS = {
Expand Down

0 comments on commit 8583330

Please sign in to comment.