0.1.2-experimental • Published 1 year ago

css-modules-extractor v0.1.2-experimental

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Extract names from SCSS / CSS modules

Package for fast extraction of module names from SCSS files. Since SCSS is backwards compatible with CSS, this package also works with CSS files.

Typically, you would do something like this:

const sassResult = sass.compile(fileName)
let cssModulesJson
const cssModulesPlugin = require('postcss-modules')({
    getJSON: (cssFileName, json) => cssModulesJson = json
})
await postcss([cssModulesPlugin])
    .process(sassResult.css, {from: fileName, to: undefined})

Basically transpiling the whole file.
But if you only want the module names (without transpiling the file), you can use this package:

const cssModulesJson = getNames(fileName)

This is about 20 times faster than compiling the SCSS and extracting the names with postcss-modules.

Warning   This package is still experimental. Some SCSS features may not be implemented yet.

Install

npm i css-modules-extractor

Options

This package accepts the same options as postcss-modules, though not all options are implemented, yet.

OptionImplemented
getJSON
localsConvention
scopeBehaviour×
globalModulePaths×
generateScopedName
hashPrefix
exportGlobals×
root×
Loader×
resolve×