babel-plugin-package-css-module

compile css module in npm package


Keywords
babel plugin, less module
License
MIT
Install
npm install babel-plugin-package-css-module@0.1.0-beta.3

Documentation

babel-plugin-package-css-module

About

Compile and use css module in npm package

  • only support less module now
  • less module files should end with .module.less

Example

/** .babelrc */
{
  "presets": [
    ...
  ],
  "plugins": [
    ["package-css-module", { "entry": "src", "output": ["lib", "es"] }],
    ...
  ]
}
/** src/index.js */
import styles from './index.module.less';

           

/**
 * es/index.js
 * 
 * src/index.module.less
 * ↓ ↓ ↓ ↓ ↓ ↓
 * es/index.module.css
 * es/index.module.css.js
 */
import './index.module.css';
import styles from './index.module.css.js';