0.0.1 • Published 8 years ago
@envato/babel-plugin-postcss-cssmodules-transform v0.0.1
babel-plugin-postcss-cssmodules-transform
Babel plugin transform and extract PostCSS and CSS Modules to static CSS
Status
This plugin is still at a very early stage and features are incomplete.
This plugin does two things:
// index.js
import styles from './index.module.css'/* index.module.css */
.root {
display: flex;
}Into an object that has properties mirroring the styles name in the compiled JS file:
// index.js
var styles = {"root":"_root_amfqe_1"};And extract to styles.css
/* styles.css */
._root_amfqe_1 {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}Usage
Install from NPM
$ yarn add @envato/babel-plugin-postcss-cssmodules-transform -DAdd the plugin to .babelrc.
{
"presets": [
["@babel/env", {
"targets": {
"browsers": ["last 2 versions"]
}
}],
"@babel/stage-3",
"@babel/react",
"@babel/typescript"
],
"plugins": [
["@envato/babel-plugin-postcss-cssmodules-transform", {
"extractCss": "./dist/styles.css"
}]
]
}Todo
- support
require('./index.module.css')syntax - support
postcss.config.js - unit test
Alternatives
This plugin is based on the two plugins below, and modified to support extractCss option with full postcss plugin support.
License
MIT
0.0.1
8 years ago