Skip to content

intrnl/postcss-modules

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

postcss-modules

PostCSS plugin for transforming CSS modules.

import postcss from 'postcss';
import modules from '@intrnl/postcss-modules';

const source = `
.foo {
  animation: rotate 1.4s linear infinite;
}

@keyframes rotate {}
`;

const processor = postcss([
  modules(),
]);

const result = processor.process(source);

result.messages;
// -> [{ type: 'export-locals', locals: { foo: { ... }, rotate: { ... } } }]

Why?

Differences with the original postcss-modules plugin:

  • Does not do linking/resolving whatsoever when composing classes.
    • This proves to be problematic when integrating the original plugin with build tools, the resolver doesn't apply to nested dependencies and thus fails if you try to do a nested compose, and the linker would lead to duplicated CSS code.
  • CSS modules is supported on a best-effort basis.
    • We only support what CSS modules is often used for: deconflicted names, and composing classes. Other syntax like @value variables are not supported.
    • We don't wrap over existing CSS modules transformation plugins, and with that we removed the overhead that is ICSS and having to run a separate CSS processor.

About

PostCSS plugin for transforming CSS modules

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published