Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
postcss-modules-extract-imports
Advanced tools
A CSS Modules transform to extract local aliases for inline imports
The postcss-modules-extract-imports npm package is a PostCSS plugin that helps in transforming CSS modules by extracting all local imports and creating a mapping for them. It is commonly used in a CSS module system where CSS is composed in a modular and reusable way. This plugin processes CSS files and rewrites import statements so that they can be bundled correctly by a module bundler.
Extracting local imports
This feature allows the plugin to extract local imports from a CSS file. When a CSS class composes from another, this plugin rewrites the import to ensure that the composed class includes the necessary styles from the imported class.
import postcss from 'postcss';
import extractImports from 'postcss-modules-extract-imports';
const css = `.className { color: green; } .anotherClass { composes: className; }`;
postcss([extractImports()])
.process(css, { from: undefined })
.then(result => {
console.log(result.css);
});
postcss-import is a PostCSS plugin that allows you to transform @import rules by inlining content. It is similar to postcss-modules-extract-imports in that it processes imports, but it focuses on inlining the imported content rather than extracting and mapping it for CSS modules.
postcss-easy-import is a wrapper around postcss-import, providing additional features like glob pattern matching and the ability to prefix imports. It simplifies the import process but does not specifically target the CSS modules pattern like postcss-modules-extract-imports.
postcss-advanced-variables is a plugin that allows you to use variables, conditionals, and iterators in your CSS. While it does not directly handle imports, it provides a modular approach to CSS that can complement the functionality provided by postcss-modules-extract-imports.
Transforms:
:local(.continueButton) {
composes: button from "library/button.css";
color: green;
}
into:
:import("library/button.css") {
button: __tmp_487387465fczSDGHSABb;
}
:local(.continueButton) {
composes: __tmp_487387465fczSDGHSABb;
color: green;
}
['composes']
alone.composes: className [... className] from "path/to/file.css";
failOnWrongOrder
bool
generates exception for unpredictable imports order..aa {
composes: b from './b.css';
composes: c from './c.css';
}
.bb {
/* "b.css" should be before "c.css" in this case */
composes: c from './c.css';
composes: b from './b.css';
}
npm install
npm test
npm watch
will watch src
for changes and rebuildnpm autotest
will watch src
and test
for changes and retestISC
Glen Maddern, 2015.
3.0.0-rc.0 - 2020-09-18
Node.js
version is >= 10.13.0 || >= 12.13.0 || >= 14
postcss
version is ^8.0.3
postcss
was moved to peerDependencies
, you need to install postcss
in your project before use the pluginFAQs
A CSS Modules transform to extract local aliases for inline imports
The npm package postcss-modules-extract-imports receives a total of 14,377,097 weekly downloads. As such, postcss-modules-extract-imports popularity was classified as popular.
We found that postcss-modules-extract-imports demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.