Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add processor css modules support #174

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

marcalexiei
Copy link
Collaborator

@marcalexiei marcalexiei commented Dec 10, 2024

Close #173

Add support of CSS modules via processor function.

When user return a cssModules property from processor output it will be used as default export from the css file.

Example

sass({
  // ...pluginOptions,
  processor: async (styles, id) => {
    let cssModules = {};
    const postcssProcessResult = await postcss([
      postcssModules({
        getJSON: (_, json) => {
          if (json) cssModules = json;
        },
      }),
    ]).process(styles, {
      from: id,
    });

    return { css: postcssProcessResult.css, cssModules };
  },
});

TODOs

  • insert unit test
  • test along other named exports
  • add documentation

@marcalexiei marcalexiei marked this pull request as draft December 10, 2024 18:27
@marcalexiei marcalexiei force-pushed the processor-css-modules branch from 87400da to d737c5d Compare December 10, 2024 18:30
@marcalexiei marcalexiei marked this pull request as ready for review December 11, 2024 10:34
@marcalexiei marcalexiei requested a review from elycruz December 11, 2024 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Question / feature request: use processor to generate CSS modules
1 participant