# css-modules-loader-core

> A loader-agnostic CSS Modules implementation, based on PostCSS

Latest version **1.1.0** (published 2017-05-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install css-modules-loader-core
pnpm add css-modules-loader-core
yarn add css-modules-loader-core
bun add css-modules-loader-core
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2017-05-22 |
| First published | 2015-06-01 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | separate (@types/css-modules-loader-core) |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 90 |
| Author | Glen Maddern |
| Maintainers | geelen, joshwnj |
| Keywords | css-modules, postcss, loader |

## Links

- npm: https://www.npmjs.com/package/css-modules-loader-core
- Repository: https://github.com/css-modules/css-modules-loader-core
- Issues: https://github.com/css-modules/css-modules-loader-core/issues
- npm.io page: https://npm.io/package/css-modules-loader-core

## Dependencies (6)

- [postcss](https://npm.io/package/postcss.md) 6.0.1
- [icss-replace-symbols](https://npm.io/package/icss-replace-symbols.md) 1.1.0
- [postcss-modules-scope](https://npm.io/package/postcss-modules-scope.md) 1.1.0
- [postcss-modules-values](https://npm.io/package/postcss-modules-values.md) 1.3.0
- [postcss-modules-extract-imports](https://npm.io/package/postcss-modules-extract-imports.md) 1.1.0
- [postcss-modules-local-by-default](https://npm.io/package/postcss-modules-local-by-default.md) 1.2.0

## Recent versions

- 1.1.0 (latest) — 2017-05-22
- 1.0.1 — 2016-08-19
- 1.0.0 — 2015-10-21
- 1.0.0-beta4 — 2015-09-22
- 1.0.0-beta3 — 2015-09-22
- 1.0.0-beta2 — 2015-09-22
- 0.0.12 — 2015-08-04
- 0.0.11 — 2015-07-02
- 0.0.10 — 2015-06-18
- 0.0.9 — 2015-06-14
- 0.0.8 — 2015-06-11
- 0.0.7 — 2015-06-09
- 0.0.6 — 2015-06-07
- 0.0.5 — 2015-06-04
- 0.0.4 — 2015-06-04
- … 3 more at https://npm.io/package/css-modules-loader-core/versions

## README

# CSS Module Loader Core
> A loader-agnostic CSS Modules implementation, based on PostCSS

[![Build Status](https://travis-ci.org/css-modules/css-modules-loader-core.svg?branch=master)](https://travis-ci.org/css-modules/css-modules-loader-core)

## API

```js
import Core from 'css-modules-loader-core'
let core = new Core()
```

### core.load( sourceString , sourcePath , pathFetcher ) =><br>&nbsp;&nbsp;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:

- `injectableSource`: the final, merged CSS file without `@import` or `:import` statements
- `exportTokens`: the mapping from local name to scoped name, as described in the file's `:export` block

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](https://github.com/css-modules/postcss-modules-local-by-default), [postcss-modules-extract-imports](https://github.com/css-modules/postcss-modules-extract-imports), [postcss-modules-scope](https://github.com/css-modules/postcss-modules-scope)] (i.e. the CSS Modules specification). This can override which PostCSS plugins you wish to execute, e.g.

```js
import Core from 'css-loader-core'
import autoprefixer from 'autoprefixer'
import colorFunctions from 'postcss-color-function'

// Don't run local-by-default, but use colorFunctions 
// beforehand and autoprefixer afterwards:
let core = new Core([
  colorFunctions, 
  core.plugins.extractImports, 
  core.plugins.scope, 
  autoprefixer("Last 2 Versions")
])
```

---
_Source: https://npm.io/package/css-modules-loader-core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
