Skip to content

css-modules/css-modules-require-hook

Repository files navigation

css-modules-require-hook

Summary

What is CSS Modules

Summary

Features

Compiling in runtime, universal apps

Usage

Requirements

To use this tool we require Node.js v0.12.x (or higher) and several modules to be installed.

Installation

$ npm i css-modules-require-hook

Tuning (options)

  • function createImportedName — short alias for the postcss-modules-extract-imports plugin's createImportedName option.
  • function generateScopedName — short alias for the postcss-modules-scope plugin's option. Helps you to specify the custom way to build generic names for the class selectors.
  • function processCss — in rare cases you may want to get compiled styles in runtime, so providing this option helps.
  • string rootDir — absolute path to the project directory. Providing this will result in better generated class names. It can be obligatory, if you run require hook and build tools (like css-modulesify) from different working directories.
  • string to — provides to option to the LazyResult instance.
  • array use — custom subset of postcss plugins.

Examples

Basically you need to require this plugin before other requires for your styles will occur.

require('css-modules-require-hook');
// ...

In rare cases you may want to tune require hook for better experience.

var hook = require('css-modules-require-hook');
var path = require('path');

hook({
  // setting root to the parent directory
  rootDir: path.join(__dirname, '..')
});

About

A require hook to compile CSS Modules in runtime

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 12