css-modules/css-modules-loader-core

Name: css-modules-loader-core

Owner: css-modules

Description: A loader-agnostic CSS Modules implementation, based on PostCSS

Created: 2015-05-28 00:11:23.0

Updated: 2018-01-20 16:20:26.0

Pushed: 2017-05-24 16:17:38.0

Homepage:

Size: 100

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

CSS Module Loader Core

A loader-agnostic CSS Modules implementation, based on PostCSS

Build Status

API
rt Core from 'css-modules-loader-core'
core = new Core()
core.load( sourceString , sourcePath , pathFetcher ) =>
  Promise({ injectableSource, exportTokens })

Processes the input CSS sourceString, looking for dependencies such as @import or :import. Any localisation will happen by prefixing a sanitised version of sourcePath When dependencies are found, it will ask the pathFetcher for each dependency, resolve & inline any imports, and return the following object:

These should map nicely to what your build-tool-specific loader needs to do its job.

new Core([plugins])

The default set of plugins is [postcss-modules-local-by-default, postcss-modules-extract-imports, postcss-modules-scope] (i.e. the CSS Modules specification). This can override which PostCSS plugins you wish to execute, e.g.

rt Core from 'css-loader-core'
rt autoprefixer from 'autoprefixer'
rt colorFunctions from 'postcss-color-function'

on't run local-by-default, but use colorFunctions 
eforehand and autoprefixer afterwards:
core = new Core([
lorFunctions, 
re.plugins.extractImports, 
re.plugins.scope, 
toprefixer("Last 2 Versions")


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.