Skip to content

Commit

Permalink
Wrap all CSS with a cascade layer
Browse files Browse the repository at this point in the history
  • Loading branch information
Janpot committed Sep 10, 2024
1 parent 445c9ce commit 2707b7d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/pigment-css-unplugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,15 @@ export const plugin = createUnplugin<PigmentOptions, true>((options) => {
}

let { cssText } = result;

const slug = slugify(cssText);

cssText = `
@layer _${slug} {
${cssText}
}
`;

if (isNext && !outputCss) {
return {
code: result.code,
Expand Down Expand Up @@ -324,7 +333,7 @@ export const plugin = createUnplugin<PigmentOptions, true>((options) => {
}

const rootPath = process.cwd();
const slug = slugify(cssText);

const cssFilename = path
.normalize(`${id.replace(/\.[jt]sx?$/, '')}-${slug}.pigment.css`)
.replace(/\\/g, path.posix.sep);
Expand Down

0 comments on commit 2707b7d

Please sign in to comment.