PostCSS runner plugin for CSS Modules
npm install karma-typescript-cssmodules-transform> Karma-Typescript :heart: CSS Modules
This plugin is a specialized PostCSS runner, which transforms CSS :exports blocks to JSON on the fly when running tests with karma-typescript.
The CSS Modules specification is implemented by running PostCSS with these plugins:
- postcss-modules-local-by-default
- postcss-modules-extract-imports
- postcss-modules-scope
- postcss-modules-values
```
$ npm install --save-dev karma-typescript-cssmodules-transform
In the karma-typescript section of karma.conf.js:
`javascript`
karmaTypescriptConfig: {
bundlerOptions: {
transforms: [
require("karma-typescript-cssmodules-transform")()
]
}
}
Custom options can be passed to the runner in the first argument when calling the plugin:
- PostCSS options. Optional, but the properties tofrom
and are _always_ set to the filename of the CSS file automatically.`
- Custom options. Optional, defaults to:javascript`
{
generateScopedName: "[name]_[local]_[hash:base64:5]",
mode: "local" // valid options are "local" | "global" | "pure"
}RegExp
- A object to filter which files should be processed./\.css$/
Optional, defaults to .
An example using a custom scope name generator string and a RegExp filter:
`javascript``
karmaTypescriptConfig: {
bundlerOptions: {
transforms: [
require("karma-typescript-cssmodules-transform")(
{}, { generateScopedName: "[local]___[hash:base64:5]" } /\.css$/
)
]
}
}
This software is licensed with the MIT license.
© 2016-2021 Erik Barke, Monounity