css-loader
Advanced tools
Comparing version
131
package.json
{ | ||
"name": "css-loader", | ||
"version": "0.28.11", | ||
"version": "6.8.1", | ||
"description": "css loader module for webpack", | ||
"license": "MIT", | ||
"repository": "webpack-contrib/css-loader", | ||
"author": "Tobias Koppers @sokra", | ||
"license": "MIT", | ||
"description": "css loader module for webpack", | ||
"homepage": "https://github.com/webpack-contrib/css-loader", | ||
"bugs": "https://github.com/webpack-contrib/css-loader/issues", | ||
"funding": { | ||
"type": "opencollective", | ||
"url": "https://opencollective.com/webpack" | ||
}, | ||
"main": "dist/cjs.js", | ||
"engines": { | ||
"node": ">=0.12.0 || >= 4.3.0 < 5.0.0 || >=5.10" | ||
"node": ">= 12.13.0" | ||
}, | ||
"scripts": { | ||
"start": "npm run build -- -w", | ||
"clean": "del-cli dist", | ||
"validate:runtime": "es-check es5 \"dist/runtime/**/*.js\"", | ||
"prebuild": "npm run clean", | ||
"build": "cross-env NODE_ENV=production babel src -d dist --copy-files", | ||
"postbuild": "npm run validate:runtime", | ||
"commitlint": "commitlint --from=master", | ||
"security": "npm audit --production", | ||
"lint:prettier": "prettier --list-different .", | ||
"lint:js": "eslint --cache .", | ||
"lint:spelling": "cspell \"**/*.*\"", | ||
"lint": "npm-run-all -l -p \"lint:**\"", | ||
"fix:js": "npm run lint:js -- --fix", | ||
"fix:prettier": "npm run lint:prettier -- --write", | ||
"fix": "npm-run-all -l fix:js fix:prettier", | ||
"test:only": "cross-env NODE_ENV=test jest", | ||
"test:watch": "npm run test:only -- --watch", | ||
"test:coverage": "npm run test:only -- --collectCoverageFrom=\"src/**/*.js\" --coverage", | ||
"pretest": "npm run lint", | ||
"test": "npm run test:coverage", | ||
"prepare": "husky install && npm run build", | ||
"release": "standard-version" | ||
}, | ||
"files": [ | ||
"lib", | ||
"index.js", | ||
"locals.js" | ||
"dist" | ||
], | ||
"peerDependencies": { | ||
"webpack": "^5.0.0" | ||
}, | ||
"dependencies": { | ||
"babel-code-frame": "^6.26.0", | ||
"css-selector-tokenizer": "^0.7.0", | ||
"cssnano": "^3.10.0", | ||
"icss-utils": "^2.1.0", | ||
"loader-utils": "^1.0.2", | ||
"lodash.camelcase": "^4.3.0", | ||
"object-assign": "^4.1.1", | ||
"postcss": "^5.0.6", | ||
"postcss-modules-extract-imports": "^1.2.0", | ||
"postcss-modules-local-by-default": "^1.2.0", | ||
"postcss-modules-scope": "^1.1.0", | ||
"postcss-modules-values": "^1.3.0", | ||
"postcss-value-parser": "^3.3.0", | ||
"source-list-map": "^2.0.0" | ||
"icss-utils": "^5.1.0", | ||
"postcss": "^8.4.21", | ||
"postcss-modules-extract-imports": "^3.0.0", | ||
"postcss-modules-local-by-default": "^4.0.3", | ||
"postcss-modules-scope": "^3.0.0", | ||
"postcss-modules-values": "^4.0.0", | ||
"postcss-value-parser": "^4.2.0", | ||
"semver": "^7.3.8" | ||
}, | ||
"devDependencies": { | ||
"codecov": "^1.0.1", | ||
"eslint": "3.14.0", | ||
"istanbul": "^0.4.5", | ||
"mocha": "^3.2.0", | ||
"should": "^11.1.2", | ||
"standard-version": "^4.0.0" | ||
"@babel/cli": "^7.21.0", | ||
"@babel/core": "^7.21.4", | ||
"@babel/preset-env": "^7.21.4", | ||
"@commitlint/cli": "^16.3.0", | ||
"@commitlint/config-conventional": "^16.2.4", | ||
"@webpack-contrib/eslint-config-webpack": "^3.0.0", | ||
"babel-jest": "^28.1.3", | ||
"cross-env": "^7.0.3", | ||
"cspell": "^6.31.1", | ||
"del": "^6.1.1", | ||
"del-cli": "^4.0.1", | ||
"es-check": "^7.1.0", | ||
"eslint": "^8.37.0", | ||
"eslint-config-prettier": "^8.8.0", | ||
"eslint-plugin-import": "^2.27.5", | ||
"file-loader": "^6.2.0", | ||
"husky": "^7.0.1", | ||
"jest": "^28.1.3", | ||
"jest-environment-jsdom": "^28.1.3", | ||
"less": "^4.1.3", | ||
"less-loader": "^10.0.1", | ||
"lint-staged": "^12.5.0", | ||
"memfs": "^3.4.13", | ||
"mini-css-extract-plugin": "^2.7.5", | ||
"npm-run-all": "^4.1.5", | ||
"postcss-loader": "^6.2.1", | ||
"postcss-preset-env": "^7.8.3", | ||
"prettier": "^2.8.7", | ||
"sass": "^1.60.0", | ||
"sass-loader": "^12.6.0", | ||
"standard-version": "^9.5.0", | ||
"strip-ansi": "^6.0.0", | ||
"style-loader": "^3.3.2", | ||
"stylus": "^0.59.0", | ||
"stylus-loader": "^6.1.0", | ||
"url-loader": "^4.1.1", | ||
"webpack": "^5.77.0" | ||
}, | ||
"scripts": { | ||
"lint": "eslint lib test", | ||
"test": "mocha", | ||
"cover": "istanbul cover node_modules/mocha/bin/_mocha", | ||
"test:cover": "npm run cover -- --report lcovonly", | ||
"travis:test": "npm run cover", | ||
"travis:lint": "npm run lint", | ||
"release": "standard-version" | ||
}, | ||
"homepage": "https://github.com/webpack-contrib/css-loader", | ||
"repository": "https://github.com/webpack-contrib/css-loader.git", | ||
"bugs": "https://github.com/webpack-contrib/css-loader/issues" | ||
"keywords": [ | ||
"webpack", | ||
"css", | ||
"loader", | ||
"url", | ||
"import" | ||
] | ||
} |
2138
README.md
@@ -1,8 +0,1 @@ | ||
[![npm][npm]][npm-url] | ||
[![node][node]][node-url] | ||
[![deps][deps]][deps-url] | ||
[![tests][tests]][tests-url] | ||
[![coverage][cover]][cover-url] | ||
[![chat][chat]][chat-url] | ||
<div align="center"> | ||
@@ -15,25 +8,49 @@ <img width="180" height="180" vspace="20" | ||
</a> | ||
<h1>CSS Loader</h1> | ||
</div> | ||
<h2 align="center">Install</h2> | ||
[![npm][npm]][npm-url] | ||
[![node][node]][node-url] | ||
[![tests][tests]][tests-url] | ||
[![coverage][cover]][cover-url] | ||
[![discussion][discussion]][discussion-url] | ||
[![size][size]][size-url] | ||
```bash | ||
# css-loader | ||
The `css-loader` interprets `@import` and `url()` like `import/require()` and will resolve them. | ||
## Getting Started | ||
> **Warning** | ||
> | ||
> To use the latest version of css-loader, webpack@5 is required | ||
To begin, you'll need to install `css-loader`: | ||
```console | ||
npm install --save-dev css-loader | ||
``` | ||
<h2 align="center">Usage</h2> | ||
or | ||
The `css-loader` interprets `@import` and `url()` like `import/require()` | ||
and will resolve them. | ||
```console | ||
yarn add -D css-loader | ||
``` | ||
Good loaders for requiring your assets are the [file-loader](https://github.com/webpack/file-loader) | ||
and the [url-loader](https://github.com/webpack/url-loader) which you should specify in your config (see [below](https://github.com/webpack-contrib/css-loader#assets)). | ||
or | ||
```console | ||
pnpm add -D css-loader | ||
``` | ||
Then add the plugin to your `webpack` config. For example: | ||
**file.js** | ||
```js | ||
import css from 'file.css'; | ||
import css from "file.css"; | ||
``` | ||
**webpack.config.js** | ||
```js | ||
@@ -44,238 +61,374 @@ module.exports = { | ||
{ | ||
test: /\.css$/, | ||
use: [ 'style-loader', 'css-loader' ] | ||
} | ||
] | ||
} | ||
} | ||
test: /\.css$/i, | ||
use: ["style-loader", "css-loader"], | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
### `toString` | ||
And run `webpack` via your preferred method. | ||
You can also use the css-loader results directly as string, such as in Angular's component style. | ||
If, for one reason or another, you need to extract CSS as a file (i.e. do not store CSS in a JS module) you might want to check out the [recommend example](https://github.com/webpack-contrib/css-loader#recommend). | ||
**webpack.config.js** | ||
## Options | ||
- **[`url`](#url)** | ||
- **[`import`](#import)** | ||
- **[`modules`](#modules)** | ||
- **[`sourceMap`](#sourcemap)** | ||
- **[`importLoaders`](#importloaders)** | ||
- **[`esModule`](#esmodule)** | ||
- **[`exportType`](#exporttype)** | ||
### `url` | ||
Type: | ||
```ts | ||
type url = | ||
| boolean | ||
| { | ||
filter: (url: string, resourcePath: string) => boolean; | ||
}; | ||
``` | ||
Default: `true` | ||
Allow to enable/disables handling the CSS functions `url` and `image-set`. | ||
If set to `false`, `css-loader` will not parse any paths specified in `url` or `image-set`. | ||
A function can also be passed to control this behavior dynamically based on the path to the asset. | ||
Starting with version [4.0.0](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#400-2020-07-25), absolute paths are parsed based on the server root. | ||
Examples resolutions: | ||
```js | ||
{ | ||
test: /\.css$/, | ||
use: [ | ||
'to-string-loader', | ||
'css-loader' | ||
] | ||
} | ||
url(image.png) => require('./image.png') | ||
url('image.png') => require('./image.png') | ||
url(./image.png) => require('./image.png') | ||
url('./image.png') => require('./image.png') | ||
url('http://dontwritehorriblecode.com/2112.png') => require('http://dontwritehorriblecode.com/2112.png') | ||
image-set(url('image2x.png') 1x, url('image1x.png') 2x) => require('./image1x.png') and require('./image2x.png') | ||
``` | ||
or | ||
To import assets from a `node_modules` path (include `resolve.modules`) and for `alias`, prefix it with a `~`: | ||
```js | ||
const css = require('./test.css').toString(); | ||
console.log(css); // {String} | ||
url(~module/image.png) => require('module/image.png') | ||
url('~module/image.png') => require('module/image.png') | ||
url(~aliasDirectory/image.png) => require('otherDirectory/image.png') | ||
``` | ||
If there are SourceMaps, they will also be included in the result string. | ||
#### `boolean` | ||
If, for one reason or another, you need to extract CSS as a | ||
plain string resource (i.e. not wrapped in a JS module) you | ||
might want to check out the [extract-loader](https://github.com/peerigon/extract-loader). | ||
It's useful when you, for instance, need to post process the CSS as a string. | ||
Enable/disable `url()` resolving. | ||
**webpack.config.js** | ||
```js | ||
{ | ||
test: /\.css$/, | ||
use: [ | ||
'handlebars-loader', // handlebars loader expects raw resource string | ||
'extract-loader', | ||
'css-loader' | ||
] | ||
} | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
url: true, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
<h2 align="center">Options</h2> | ||
#### `object` | ||
|Name|Type|Default|Description| | ||
|:--:|:--:|:-----:|:----------| | ||
|**[`root`](#root)**|`{String}`|`/`|Path to resolve URLs, URLs starting with `/` will not be translated| | ||
|**[`url`](#url)**|`{Boolean}`|`true`| Enable/Disable `url()` handling| | ||
|**[`alias`](#alias)**|`{Object}`|`{}`|Create aliases to import certain modules more easily| | ||
|**[`import`](#import)** |`{Boolean}`|`true`| Enable/Disable @import handling| | ||
|**[`modules`](#modules)**|`{Boolean}`|`false`|Enable/Disable CSS Modules| | ||
|**[`minimize`](#minimize)**|`{Boolean\|Object}`|`false`|Enable/Disable minification| | ||
|**[`sourceMap`](#sourcemap)**|`{Boolean}`|`false`|Enable/Disable Sourcemaps| | ||
|**[`camelCase`](#camelcase)**|`{Boolean\|String}`|`false`|Export Classnames in CamelCase| | ||
|**[`importLoaders`](#importloaders)**|`{Number}`|`0`|Number of loaders applied before CSS loader| | ||
|**`localIdentName`**|`{String}`|`[hash:base64]`|Configure the generated ident| | ||
Allow to filter `url()`. All filtered `url()` will not be resolved (left in the code as they were written). | ||
### `root` | ||
**webpack.config.js** | ||
For URLs that start with a `/`, the default behavior is to not translate them. | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
url: { | ||
filter: (url, resourcePath) => { | ||
// resourcePath - path to css file | ||
`url(/image.png) => url(/image.png)` | ||
// Don't handle `img.png` urls | ||
if (url.includes("img.png")) { | ||
return false; | ||
} | ||
If a `root` query parameter is set, however, it will be prepended to the URL | ||
and then translated. | ||
// Don't handle images under root-relative /external_images/ | ||
if (/^\/external_images\//.test(path)) { | ||
return false; | ||
} | ||
**webpack.config.js** | ||
```js | ||
{ | ||
loader: 'css-loader', | ||
options: { root: '.' } | ||
} | ||
return true; | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
`url(/image.png)` => `require('./image.png')` | ||
### `import` | ||
Using 'Root-relative' urls is not recommended. You should only use it for legacy CSS files. | ||
Type: | ||
### `url` | ||
<!-- use other name to prettify since import is reserved keyword --> | ||
To disable `url()` resolving by `css-loader` set the option to `false`. | ||
```ts | ||
type importFn = | ||
| boolean | ||
| { | ||
filter: ( | ||
url: string, | ||
media: string, | ||
resourcePath: string, | ||
supports?: string, | ||
layer?: string | ||
) => boolean; | ||
}; | ||
``` | ||
To be compatible with existing css files (if not in CSS Module mode). | ||
Default: `true` | ||
Allows to enables/disables `@import` at-rules handling. | ||
Control `@import` resolving. Absolute urls in `@import` will be moved in runtime code. | ||
Examples resolutions: | ||
``` | ||
url(image.png) => require('./image.png') | ||
url(~module/image.png) => require('module/image.png') | ||
@import 'style.css' => require('./style.css') | ||
@import url(style.css) => require('./style.css') | ||
@import url('style.css') => require('./style.css') | ||
@import './style.css' => require('./style.css') | ||
@import url(./style.css) => require('./style.css') | ||
@import url('./style.css') => require('./style.css') | ||
@import url('http://dontwritehorriblecode.com/style.css') => @import url('http://dontwritehorriblecode.com/style.css') in runtime | ||
``` | ||
### `alias` | ||
To import styles from a `node_modules` path (include `resolve.modules`) and for `alias`, prefix it with a `~`: | ||
Rewrite your urls with alias, this is useful when it's hard to change url paths of your input files, for example, when you're using some css / sass files in another package (bootstrap, ratchet, font-awesome, etc.). | ||
``` | ||
@import url(~module/style.css) => require('module/style.css') | ||
@import url('~module/style.css') => require('module/style.css') | ||
@import url(~aliasDirectory/style.css) => require('otherDirectory/style.css') | ||
``` | ||
`css-loader`'s `alias` follows the same syntax as webpack's `resolve.alias`, you can see the details at the [resolve docs](https://webpack.js.org/configuration/resolve/#resolve-alias) | ||
#### `boolean` | ||
**file.scss** | ||
```css | ||
@charset "UTF-8"; | ||
@import "bootstrap"; | ||
``` | ||
Enable/disable `@import` resolving. | ||
**webpack.config.js** | ||
```js | ||
{ | ||
test: /\.scss$/, | ||
use: [ | ||
{ | ||
loader: "style-loader" | ||
}, | ||
{ | ||
loader: "css-loader", | ||
options: { | ||
alias: { | ||
"../fonts/bootstrap": "bootstrap-sass/assets/fonts/bootstrap" | ||
} | ||
} | ||
}, | ||
{ | ||
loader: "sass-loader", | ||
options: { | ||
includePaths: [ | ||
path.resolve("./node_modules/bootstrap-sass/assets/stylesheets") | ||
] | ||
} | ||
} | ||
] | ||
} | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
import: true, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
Check out this [working bootstrap example](https://github.com/bbtfr/webpack2-bootstrap-sass-sample). | ||
#### `object` | ||
### `import` | ||
##### `filter` | ||
To disable `@import` resolving by `css-loader` set the option to `false` | ||
Type: | ||
```css | ||
@import url('https://fonts.googleapis.com/css?family=Roboto'); | ||
```ts | ||
type filter = (url: string, media: string, resourcePath: string) => boolean; | ||
``` | ||
> _⚠️ Use with caution, since this disables resolving for **all** `@import`s, including css modules `composes: xxx from 'path/to/file.css'` feature._ | ||
Default: `undefined` | ||
### [`modules`](https://github.com/css-modules/css-modules) | ||
Allow to filter `@import`. All filtered `@import` will not be resolved (left in the code as they were written). | ||
The query parameter `modules` enables the **CSS Modules** spec. | ||
**webpack.config.js** | ||
This enables local scoped CSS by default. (You can switch it off with `:global(...)` or `:global` for selectors and/or rules.). | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
import: { | ||
filter: (url, media, resourcePath) => { | ||
// resourcePath - path to css file | ||
#### `Scope` | ||
// Don't handle `style.css` import | ||
if (url.includes("style.css")) { | ||
return false; | ||
} | ||
By default CSS exports all classnames into a global selector scope. Styles can be locally scoped to avoid globally scoping styles. | ||
return true; | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
The syntax `:local(.className)` can be used to declare `className` in the local scope. The local identifiers are exported by the module. | ||
### `modules` | ||
With `:local` (without brackets) local mode can be switched on for this selector. `:global(.className)` can be used to declare an explicit global selector. With `:global` (without brackets) global mode can be switched on for this selector. | ||
Type: | ||
The loader replaces local selectors with unique identifiers. The choosen unique identifiers are exported by the module. | ||
```css | ||
:local(.className) { background: red; } | ||
:local .className { color: green; } | ||
:local(.className .subClass) { color: green; } | ||
:local .className .subClass :global(.global-class-name) { color: blue; } | ||
```ts | ||
type modules = | ||
| boolean | ||
| "local" | ||
| "global" | ||
| "pure" | ||
| "icss" | ||
| { | ||
auto: boolean | regExp | ((resourcePath: string) => boolean); | ||
mode: | ||
| "local" | ||
| "global" | ||
| "pure" | ||
| "icss" | ||
| ((resourcePath) => "local" | "global" | "pure" | "icss"); | ||
localIdentName: string; | ||
localIdentContext: string; | ||
localIdentHashSalt: string; | ||
localIdentHashFunction: string; | ||
localIdentHashDigest: string; | ||
localIdentRegExp: string | regExp; | ||
getLocalIdent: ( | ||
context: LoaderContext, | ||
localIdentName: string, | ||
localName: string | ||
) => string; | ||
namedExport: boolean; | ||
exportGlobals: boolean; | ||
exportLocalsConvention: | ||
| "asIs" | ||
| "camelCase" | ||
| "camelCaseOnly" | ||
| "dashes" | ||
| "dashesOnly" | ||
| ((name: string) => string); | ||
exportOnlyLocals: boolean; | ||
}; | ||
``` | ||
```css | ||
._23_aKvs-b8bW2Vg3fwHozO { background: red; } | ||
._23_aKvs-b8bW2Vg3fwHozO { color: green; } | ||
._23_aKvs-b8bW2Vg3fwHozO ._13LGdX8RMStbBE9w-t0gZ1 { color: green; } | ||
._23_aKvs-b8bW2Vg3fwHozO ._13LGdX8RMStbBE9w-t0gZ1 .global-class-name { color: blue; } | ||
``` | ||
Default: `undefined` | ||
> :information_source: Identifiers are exported | ||
Allows to enable/disable CSS Modules or ICSS and setup configuration: | ||
- `undefined` - enable CSS modules for all files matching `/\.module\.\w+$/i.test(filename)` and `/\.icss\.\w+$/i.test(filename)` regexp. | ||
- `true` - enable CSS modules for all files. | ||
- `false` - disables CSS Modules for all files. | ||
- `string` - disables CSS Modules for all files and set the `mode` option, more information you can read [here](https://github.com/webpack-contrib/css-loader#mode) | ||
- `object` - enable CSS modules for all files, if `modules.auto` option is not specified, otherwise the `modules.auto` option will determine whether if it is CSS modules or not, more information you can read [here](https://github.com/webpack-contrib/css-loader#auto) | ||
The `modules` option enables/disables the **[CSS Modules](https://github.com/css-modules/css-modules)** specification and setup basic behaviour. | ||
Using `false` value increase performance because we avoid parsing **CSS Modules** features, it will be useful for developers who use vanilla css or use other technologies. | ||
**webpack.config.js** | ||
```js | ||
exports.locals = { | ||
className: '_23_aKvs-b8bW2Vg3fwHozO', | ||
subClass: '_13LGdX8RMStbBE9w-t0gZ1' | ||
} | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
modules: true, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
CamelCase is recommended for local selectors. They are easier to use in the within the imported JS module. | ||
#### `Features` | ||
`url()` URLs in block scoped (`:local .abc`) rules behave like requests in modules. | ||
##### `Scope` | ||
``` | ||
file.png => ./file.png | ||
~module/file.png => module/file.png | ||
``` | ||
Using `local` value requires you to specify `:global` classes. | ||
Using `global` value requires you to specify `:local` classes. | ||
Using `pure` value requires selectors must contain at least one local class or id. | ||
You can use `:local(#someId)`, but this is not recommended. Use classes instead of ids. | ||
You can configure the generated ident with the `localIdentName` query parameter (default `[hash:base64]`). | ||
You can find more information [here](https://github.com/css-modules/css-modules). | ||
**webpack.config.js** | ||
```js | ||
{ | ||
test: /\.css$/, | ||
use: [ | ||
{ | ||
loader: 'css-loader', | ||
options: { | ||
modules: true, | ||
localIdentName: '[path][name]__[local]--[hash:base64:5]' | ||
} | ||
} | ||
] | ||
Styles can be locally scoped to avoid globally scoping styles. | ||
The syntax `:local(.className)` can be used to declare `className` in the local scope. The local identifiers are exported by the module. | ||
With `:local` (without brackets) local mode can be switched on for this selector. | ||
The `:global(.className)` notation can be used to declare an explicit global selector. | ||
With `:global` (without brackets) global mode can be switched on for this selector. | ||
The loader replaces local selectors with unique identifiers. The chosen unique identifiers are exported by the module. | ||
```css | ||
:local(.className) { | ||
background: red; | ||
} | ||
:local .className { | ||
color: green; | ||
} | ||
:local(.className .subClass) { | ||
color: green; | ||
} | ||
:local .className .subClass :global(.global-class-name) { | ||
color: blue; | ||
} | ||
``` | ||
You can also specify the absolute path to your custom `getLocalIdent` function to generate classname based on a different schema. This requires `webpack >= 2.2.1` (it supports functions in the `options` object). | ||
```css | ||
._23_aKvs-b8bW2Vg3fwHozO { | ||
background: red; | ||
} | ||
._23_aKvs-b8bW2Vg3fwHozO { | ||
color: green; | ||
} | ||
._23_aKvs-b8bW2Vg3fwHozO ._13LGdX8RMStbBE9w-t0gZ1 { | ||
color: green; | ||
} | ||
._23_aKvs-b8bW2Vg3fwHozO ._13LGdX8RMStbBE9w-t0gZ1 .global-class-name { | ||
color: blue; | ||
} | ||
``` | ||
**webpack.config.js** | ||
> **Note** | ||
> | ||
> Identifiers are exported | ||
```js | ||
{ | ||
loader: 'css-loader', | ||
options: { | ||
modules: true, | ||
localIdentName: '[path][name]__[local]--[hash:base64:5]', | ||
getLocalIdent: (context, localIdentName, localName, options) => { | ||
return 'whatever_random_class_name' | ||
} | ||
} | ||
} | ||
exports.locals = { | ||
className: "_23_aKvs-b8bW2Vg3fwHozO", | ||
subClass: "_13LGdX8RMStbBE9w-t0gZ1", | ||
}; | ||
``` | ||
> :information_source: For prerendering with extract-text-webpack-plugin you should use `css-loader/locals` instead of `style-loader!css-loader` **in the prerendering bundle**. It doesn't embed CSS but only exports the identifier mappings. | ||
CamelCase is recommended for local selectors. They are easier to use within the imported JS module. | ||
#### `Composing` | ||
You can use `:local(#someId)`, but this is not recommended. Use classes instead of ids. | ||
##### `Composing` | ||
When declaring a local classname you can compose a local class from another local classname. | ||
@@ -299,8 +452,8 @@ | ||
exports.locals = { | ||
className: '_23_aKvs-b8bW2Vg3fwHozO', | ||
subClass: '_13LGdX8RMStbBE9w-t0gZ1 _23_aKvs-b8bW2Vg3fwHozO' | ||
} | ||
className: "_23_aKvs-b8bW2Vg3fwHozO", | ||
subClass: "_13LGdX8RMStbBE9w-t0gZ1 _23_aKvs-b8bW2Vg3fwHozO", | ||
}; | ||
``` | ||
``` css | ||
```css | ||
._23_aKvs-b8bW2Vg3fwHozO { | ||
@@ -316,9 +469,13 @@ background: red; | ||
#### `Importing` | ||
##### `Importing` | ||
To import a local classname from another module. | ||
> **Note** | ||
> | ||
> We strongly recommend that you specify the extension when importing a file, since it is possible to import a file with any extension and it is not known in advance which file to use. | ||
```css | ||
:local(.continueButton) { | ||
composes: button from 'library/button.css'; | ||
composes: button from "library/button.css"; | ||
background: red; | ||
@@ -330,3 +487,3 @@ } | ||
:local(.nameEdit) { | ||
composes: edit highlight from './edit.css'; | ||
composes: edit highlight from "./edit.css"; | ||
background: red; | ||
@@ -340,4 +497,4 @@ } | ||
:local(.className) { | ||
composes: edit hightlight from './edit.css'; | ||
composes: button from 'module/button.css'; | ||
composes: edit highlight from "./edit.css"; | ||
composes: button from "module/button.css"; | ||
composes: classFromThisModule; | ||
@@ -348,16 +505,25 @@ background: red; | ||
### `minimize` | ||
##### `Values` | ||
By default the css-loader minimizes the css if specified by the module system. | ||
You can use `@value` to specific values to be reused throughout a document. | ||
In some cases the minification is destructive to the css, so you can provide your own options to the cssnano-based minifier if needed. See [cssnano's documentation](http://cssnano.co/guides/) for more information on the available options. | ||
We recommend use prefix `v-` for values, `s-` for selectors and `m-` for media at-rules. | ||
You can also disable or enforce minification with the `minimize` query parameter. | ||
```css | ||
@value v-primary: #BF4040; | ||
@value s-black: black-selector; | ||
@value m-large: (min-width: 960px); | ||
**webpack.config.js** | ||
```js | ||
{ | ||
loader: 'css-loader', | ||
options: { | ||
minimize: true || {/* CSSNano Options */} | ||
.header { | ||
color: v-primary; | ||
padding: 0 10px; | ||
} | ||
.s-black { | ||
color: black; | ||
} | ||
@media m-large { | ||
.header { | ||
padding: 0 20px; | ||
} | ||
@@ -367,82 +533,894 @@ } | ||
### `sourceMap` | ||
#### `boolean` | ||
To include source maps set the `sourceMap` option. | ||
Enable **CSS Modules** features. | ||
I. e. the extract-text-webpack-plugin can handle them. | ||
**webpack.config.js** | ||
They are not enabled by default because they expose a runtime overhead and increase in bundle size (JS source maps do not). In addition to that relative paths are buggy and you need to use an absolute public path which include the server URL. | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
modules: true, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
#### `string` | ||
Enable **CSS Modules** features and setup `mode`. | ||
**webpack.config.js** | ||
```js | ||
{ | ||
loader: 'css-loader', | ||
options: { | ||
sourceMap: true | ||
} | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
// Using `local` value has same effect like using `modules: true` | ||
modules: "global", | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
#### `object` | ||
Enable **CSS Modules** features and setup options for them. | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
modules: { | ||
mode: "local", | ||
auto: true, | ||
exportGlobals: true, | ||
localIdentName: "[path][name]__[local]--[hash:base64:5]", | ||
localIdentContext: path.resolve(__dirname, "src"), | ||
localIdentHashSalt: "my-custom-hash", | ||
namedExport: true, | ||
exportLocalsConvention: "camelCase", | ||
exportOnlyLocals: false, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
##### `auto` | ||
Type: | ||
```ts | ||
type auto = boolean | regExp | ((resourcePath: string) => boolean); | ||
``` | ||
Default: `undefined` | ||
Allows auto enable CSS modules/ICSS based on filename when `modules` option is object. | ||
Possible values: | ||
- `undefined` - enable CSS modules for all files. | ||
- `true` - enable CSS modules for all files matching `/\.module\.\w+$/i.test(filename)` and `/\.icss\.\w+$/i.test(filename)` regexp. | ||
- `false` - disables CSS Modules. | ||
- `RegExp` - enable CSS modules for all files matching `/RegExp/i.test(filename)` regexp. | ||
- `function` - enable CSS Modules for files based on the filename satisfying your filter function check. | ||
###### `boolean` | ||
Possible values: | ||
- `true` - enables CSS modules or interoperable CSS format, sets the [`modules.mode`](#mode) option to `local` value for all files which satisfy `/\.module(s)?\.\w+$/i.test(filename)` condition or sets the [`modules.mode`](#mode) option to `icss` value for all files which satisfy `/\.icss\.\w+$/i.test(filename)` condition | ||
- `false` - disables CSS modules or interoperable CSS format based on filename | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
modules: { | ||
auto: true, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
###### `RegExp` | ||
Enable CSS modules for files based on the filename satisfying your regex check. | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
modules: { | ||
auto: /\.custom-module\.\w+$/i, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
###### `function` | ||
Enable CSS modules for files based on the filename satisfying your filter function check. | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
modules: { | ||
auto: (resourcePath) => resourcePath.endsWith(".custom-module.css"), | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
##### `mode` | ||
Type: | ||
```ts | ||
type mode = | ||
| "local" | ||
| "global" | ||
| "pure" | ||
| "icss" | ||
| ((resourcePath: string) => "local" | "global" | "pure" | "icss"); | ||
``` | ||
Default: `'local'` | ||
Setup `mode` option. You can omit the value when you want `local` mode. | ||
Controls the level of compilation applied to the input styles. | ||
The `local`, `global`, and `pure` handles `class` and `id` scoping and `@value` values. | ||
The `icss` will only compile the low level `Interoperable CSS` format for declaring `:import` and `:export` dependencies between CSS and other languages. | ||
ICSS underpins CSS Module support, and provides a low level syntax for other tools to implement CSS-module variations of their own. | ||
###### `string` | ||
Possible values - `local`, `global`, `pure`, and `icss`. | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
modules: { | ||
mode: "global", | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
###### `function` | ||
Allows set different values for the `mode` option based on a filename | ||
Possible return values - `local`, `global`, `pure` and `icss`. | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
modules: { | ||
// Callback must return "local", "global", or "pure" values | ||
mode: (resourcePath) => { | ||
if (/pure.css$/i.test(resourcePath)) { | ||
return "pure"; | ||
} | ||
if (/global.css$/i.test(resourcePath)) { | ||
return "global"; | ||
} | ||
return "local"; | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
##### `localIdentName` | ||
Type: | ||
```ts | ||
type localIdentName = string; | ||
``` | ||
Default: `'[hash:base64]'` | ||
Allows to configure the generated local ident name. | ||
For more information on options see: | ||
- [webpack template strings](https://webpack.js.org/configuration/output/#template-strings), | ||
- [output.hashDigest](https://webpack.js.org/configuration/output/#outputhashdigest), | ||
- [output.hashDigestLength](https://webpack.js.org/configuration/output/#outputhashdigestlength), | ||
- [output.hashFunction](https://webpack.js.org/configuration/output/#outputhashfunction), | ||
- [output.hashSalt](https://webpack.js.org/configuration/output/#outputhashsalt). | ||
Supported template strings: | ||
- `[name]` the basename of the resource | ||
- `[folder]` the folder the resource relative to the `compiler.context` option or `modules.localIdentContext` option. | ||
- `[path]` the path of the resource relative to the `compiler.context` option or `modules.localIdentContext` option. | ||
- `[file]` - filename and path. | ||
- `[ext]` - extension with leading `.`. | ||
- `[hash]` - the hash of the string, generated based on `localIdentHashSalt`, `localIdentHashFunction`, `localIdentHashDigest`, `localIdentHashDigestLength`, `localIdentContext`, `resourcePath` and `exportName` | ||
- `[<hashFunction>:hash:<hashDigest>:<hashDigestLength>]` - hash with hash settings. | ||
- `[local]` - original class. | ||
Recommendations: | ||
- use `'[path][name]__[local]'` for development | ||
- use `'[hash:base64]'` for production | ||
The `[local]` placeholder contains original class. | ||
**Note:** all reserved (`<>:"/\|?*`) and control filesystem characters (excluding characters in the `[local]` placeholder) will be converted to `-`. | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
modules: { | ||
localIdentName: "[path][name]__[local]--[hash:base64:5]", | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
##### `localIdentContext` | ||
Type: | ||
```ts | ||
type localIdentContex = string; | ||
``` | ||
Default: `compiler.context` | ||
Allows to redefine basic loader context for local ident name. | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
modules: { | ||
localIdentContext: path.resolve(__dirname, "src"), | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
##### `localIdentHashSalt` | ||
Type: | ||
```ts | ||
type localIdentHashSalt = string; | ||
``` | ||
Default: `undefined` | ||
Allows to add custom hash to generate more unique classes. | ||
For more information see [output.hashSalt](https://webpack.js.org/configuration/output/#outputhashsalt). | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
modules: { | ||
localIdentHashSalt: "hash", | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
##### `localIdentHashFunction` | ||
Type: | ||
```ts | ||
type localIdentHashFunction = string; | ||
``` | ||
Default: `md4` | ||
Allows to specify hash function to generate classes . | ||
For more information see [output.hashFunction](https://webpack.js.org/configuration/output/#outputhashfunction). | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
modules: { | ||
localIdentHashFunction: "md4", | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
##### `localIdentHashDigest` | ||
Type: | ||
```ts | ||
type localIdentHashDigest = string; | ||
``` | ||
Default: `hex` | ||
Allows to specify hash digest to generate classes. | ||
For more information see [output.hashDigest](https://webpack.js.org/configuration/output/#outputhashdigest). | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
modules: { | ||
localIdentHashDigest: "base64", | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
##### `localIdentHashDigestLength` | ||
Type: | ||
```ts | ||
type localIdentHashDigestLength = number; | ||
``` | ||
Default: `20` | ||
Allows to specify hash digest length to generate classes. | ||
For more information see [output.hashDigestLength](https://webpack.js.org/configuration/output/#outputhashdigestlength). | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
modules: { | ||
localIdentHashDigestLength: 5, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
##### `hashStrategy` | ||
Type: `'resource-path-and-local-name' | 'minimal-subset'` | ||
Default: `'resource-path-and-local-name'` | ||
Should local name be used when computing the hash. | ||
- `'resource-path-and-local-name'` Both resource path and local name are used when hashing. Each identifier in a module gets its own hash digest, always. | ||
- `'minimal-subset'` Auto detect if identifier names can be omitted from hashing. Use this value to optimize the output for better GZIP or Brotli compression. | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
modules: { | ||
hashStrategy: "minimal-subset", | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
##### `localIdentRegExp` | ||
Type: | ||
```ts | ||
type localIdentRegExp = string | RegExp; | ||
``` | ||
Default: `undefined` | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
modules: { | ||
localIdentRegExp: /page-(.*)\.css/i, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
##### `getLocalIdent` | ||
Type: | ||
```ts | ||
type getLocalIdent = ( | ||
context: LoaderContext, | ||
localIdentName: string, | ||
localName: string | ||
) => string; | ||
``` | ||
Default: `undefined` | ||
Allows to specify a function to generate the classname. | ||
By default we use built-in function to generate a classname. | ||
If the custom function returns `null` or `undefined`, we fallback to the | ||
built-in function to generate the classname. | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
modules: { | ||
getLocalIdent: (context, localIdentName, localName, options) => { | ||
return "whatever_random_class_name"; | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
##### `namedExport` | ||
Type: | ||
```ts | ||
type namedExport = boolean; | ||
``` | ||
Default: `false` | ||
Enables/disables ES modules named export for locals. | ||
> **Warning** | ||
> | ||
> Names of locals are converted to camelcase, i.e. the `exportLocalsConvention` option has `camelCaseOnly` value by default. | ||
> **Warning** | ||
> | ||
> It is not allowed to use JavaScript reserved words in css class names. | ||
**styles.css** | ||
```css | ||
.foo-baz { | ||
color: red; | ||
} | ||
.bar { | ||
color: blue; | ||
} | ||
``` | ||
### `camelCase` | ||
**index.js** | ||
By default, the exported JSON keys mirror the class names. If you want to camelize class names (useful in JS), pass the query parameter `camelCase` to css-loader. | ||
```js | ||
import { fooBaz, bar } from "./styles.css"; | ||
|Name|Type|Description| | ||
|:--:|:--:|:----------| | ||
|**`true`**|`{Boolean}`|Class names will be camelized| | ||
|**`'dashes'`**|`{String}`|Only dashes in class names will be camelized| | ||
|**`'only'`** |`{String}`|Introduced in `0.27.1`. Class names will be camelized, the original class name will be removed from the locals| | ||
|**`'dashesOnly'`**|`{String}`|Introduced in `0.27.1`. Dashes in class names will be camelized, the original class name will be removed from the locals| | ||
console.log(fooBaz, bar); | ||
``` | ||
You can enable a ES module named export using: | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
esModule: true, | ||
modules: { | ||
namedExport: true, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
To set a custom name for namedExport, can use [`exportLocalsConvention`](#exportLocalsConvention) option as a function. | ||
Example below in the [`examples`](#examples) section. | ||
##### `exportGlobals` | ||
Type: | ||
```ts | ||
type exportsGLobals = boolean; | ||
``` | ||
Default: `false` | ||
Allow `css-loader` to export names from global class or id, so you can use that as local name. | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
modules: { | ||
exportGlobals: true, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
##### `exportLocalsConvention` | ||
Type: | ||
```ts | ||
type exportLocalsConvention = | ||
| "asIs" | ||
| "camelCase" | ||
| "camelCaseOnly" | ||
| "dashes" | ||
| "dashesOnly" | ||
| ((name: string) => string); | ||
``` | ||
Default: based on the `modules.namedExport` option value, if `true` - `camelCaseOnly`, otherwise `asIs` | ||
Style of exported class names. | ||
###### `string` | ||
By default, the exported JSON keys mirror the class names (i.e `asIs` value). | ||
> **Warning** | ||
> | ||
> Only `camelCaseOnly` value allowed if you set the `namedExport` value to `true`. | ||
| Name | Type | Description | | ||
| :-------------------: | :------: | :----------------------------------------------------------------------------------------------- | | ||
| **`'asIs'`** | `string` | Class names will be exported as is. | | ||
| **`'camelCase'`** | `string` | Class names will be camelized, the original class name will not to be removed from the locals | | ||
| **`'camelCaseOnly'`** | `string` | Class names will be camelized, the original class name will be removed from the locals | | ||
| **`'dashes'`** | `string` | Only dashes in class names will be camelized | | ||
| **`'dashesOnly'`** | `string` | Dashes in class names will be camelized, the original class name will be removed from the locals | | ||
**file.css** | ||
```css | ||
.class-name {} | ||
.class-name { | ||
} | ||
``` | ||
**file.js** | ||
```js | ||
import { className } from 'file.css'; | ||
import { className } from "file.css"; | ||
``` | ||
**webpack.config.js** | ||
```js | ||
{ | ||
loader: 'css-loader', | ||
options: { | ||
camelCase: true | ||
} | ||
} | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
modules: { | ||
exportLocalsConvention: "camelCase", | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
###### `function` | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
modules: { | ||
exportLocalsConvention: function (name) { | ||
return name.replace(/-/g, "_"); | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
modules: { | ||
exportLocalsConvention: function (name) { | ||
return [ | ||
name.replace(/-/g, "_"), | ||
// dashesCamelCase | ||
name.replace(/-+(\w)/g, (match, firstLetter) => | ||
firstLetter.toUpperCase() | ||
), | ||
]; | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
##### `exportOnlyLocals` | ||
Type: | ||
```ts | ||
type exportOnlyLocals = boolean; | ||
``` | ||
Default: `false` | ||
Export only locals. | ||
**Useful** when you use **css modules** for pre-rendering (for example SSR). | ||
For pre-rendering with `mini-css-extract-plugin` you should use this option instead of `style-loader!css-loader` **in the pre-rendering bundle**. | ||
It doesn't embed CSS but only exports the identifier mappings. | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
modules: { | ||
exportOnlyLocals: true, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
### `importLoaders` | ||
The query parameter `importLoaders` allows to configure how many loaders before `css-loader` should be applied to `@import`ed resources. | ||
Type: | ||
```ts | ||
type importLoaders = number; | ||
``` | ||
Default: `0` | ||
Allows to enables/disables or setups number of loaders applied before CSS loader for `@import` at-rules, CSS modules and ICSS imports, i.e. `@import`/`composes`/`@value value from './values.css'`/etc. | ||
The option `importLoaders` allows you to configure how many loaders before `css-loader` should be applied to `@import`ed resources and CSS modules/ICSS imports. | ||
**webpack.config.js** | ||
```js | ||
{ | ||
test: /\.css$/, | ||
use: [ | ||
'style-loader', | ||
{ | ||
loader: 'css-loader', | ||
options: { | ||
importLoaders: 2 // 0 => no loaders (default); 1 => postcss-loader; 2 => postcss-loader, sass-loader | ||
} | ||
}, | ||
'postcss-loader', | ||
'sass-loader' | ||
] | ||
} | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
use: [ | ||
"style-loader", | ||
{ | ||
loader: "css-loader", | ||
options: { | ||
importLoaders: 2, | ||
// 0 => no loaders (default); | ||
// 1 => postcss-loader; | ||
// 2 => postcss-loader, sass-loader | ||
}, | ||
}, | ||
"postcss-loader", | ||
"sass-loader", | ||
], | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
This may change in the future, when the module system (i. e. webpack) supports loader matching by origin. | ||
This may change in the future when the module system (i. e. webpack) supports loader matching by origin. | ||
<h2 align="center">Examples</h2> | ||
### `sourceMap` | ||
### Assets | ||
Type: | ||
The following `webpack.config.js` can load CSS files, embed small PNG/JPG/GIF/SVG images as well as fonts as [Data URLs](https://tools.ietf.org/html/rfc2397) and copy larger files to the output directory. | ||
```ts | ||
type sourceMap = boolean; | ||
``` | ||
Default: depends on the `compiler.devtool` value | ||
By default generation of source maps depends on the [`devtool`](https://webpack.js.org/configuration/devtool/) option. All values enable source map generation except `eval` and `false` value. | ||
**webpack.config.js** | ||
```js | ||
@@ -453,27 +1431,449 @@ module.exports = { | ||
{ | ||
test: /\.css$/, | ||
use: [ 'style-loader', 'css-loader' ] | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
sourceMap: true, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
### `esModule` | ||
Type: | ||
```ts | ||
type esModule = boolean; | ||
``` | ||
Default: `true` | ||
By default, `css-loader` generates JS modules that use the ES modules syntax. | ||
There are some cases in which using ES modules is beneficial, like in the case of [module concatenation](https://webpack.js.org/plugins/module-concatenation-plugin/) and [tree shaking](https://webpack.js.org/guides/tree-shaking/). | ||
You can enable a CommonJS modules syntax using: | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/, | ||
loader: 'url-loader', | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
limit: 10000 | ||
} | ||
} | ||
] | ||
} | ||
esModule: false, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
### `exportType` | ||
Type: | ||
```ts | ||
type exportType = "array" | "string" | "css-style-sheet"; | ||
``` | ||
Default: `'array'` | ||
Allows exporting styles as array with modules, string or [constructable stylesheet](https://developers.google.com/web/updates/2019/02/constructable-stylesheets) (i.e. [`CSSStyleSheet`](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet)). | ||
Default value is `'array'`, i.e. loader exports array of modules with specific API which is used in `style-loader` or other. | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
assert: { type: "css" }, | ||
loader: "css-loader", | ||
options: { | ||
exportType: "css-style-sheet", | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
**src/index.js** | ||
```js | ||
import sheet from "./styles.css" assert { type: "css" }; | ||
document.adoptedStyleSheets = [sheet]; | ||
shadowRoot.adoptedStyleSheets = [sheet]; | ||
``` | ||
#### `'array'` | ||
The default export is array of modules with specific API which is used in `style-loader` or other. | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(sa|sc|c)ss$/i, | ||
use: ["style-loader", "css-loader", "postcss-loader", "sass-loader"], | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
**src/index.js** | ||
```js | ||
// `style-loader` applies styles to DOM | ||
import "./styles.css"; | ||
``` | ||
#### `'string'` | ||
> **Warning** | ||
> | ||
> You don't need [`style-loader`](https://github.com/webpack-contrib/style-loader) anymore, please remove it. | ||
> **Warning** | ||
> | ||
> The `esModules` option should be enabled if you want to use it with [`CSS modules`](https://github.com/webpack-contrib/css-loader#modules), by default for locals will be used [named export](https://github.com/webpack-contrib/css-loader#namedexport). | ||
The default export is `string`. | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(sa|sc|c)ss$/i, | ||
use: ["css-loader", "postcss-loader", "sass-loader"], | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
**src/index.js** | ||
```js | ||
import sheet from "./styles.css"; | ||
console.log(sheet); | ||
``` | ||
#### `'css-style-sheet'` | ||
> **Warning** | ||
> | ||
> `@import` rules not yet allowed, more [information](https://web.dev/css-module-scripts/#@import-rules-not-yet-allowed) | ||
> **Warning** | ||
> | ||
> You don't need [`style-loader`](https://github.com/webpack-contrib/style-loader) anymore, please remove it. | ||
> **Warning** | ||
> | ||
> The `esModules` option should be enabled if you want to use it with [`CSS modules`](https://github.com/webpack-contrib/css-loader#modules), by default for locals will be used [named export](https://github.com/webpack-contrib/css-loader#namedexport). | ||
> **Warning** | ||
> | ||
> Source maps are not currently supported in `Chrome` due [bug](https://bugs.chromium.org/p/chromium/issues/detail?id=1174094&q=CSSStyleSheet%20source%20maps&can=2) | ||
The default export is a [constructable stylesheet](https://developers.google.com/web/updates/2019/02/constructable-stylesheets) (i.e. [`CSSStyleSheet`](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet)). | ||
Useful for [custom elements](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements) and shadow DOM. | ||
More information: | ||
- [Using CSS Module Scripts to import stylesheets](https://web.dev/css-module-scripts/) | ||
- [Constructable Stylesheets: seamless reusable styles](https://developers.google.com/web/updates/2019/02/constructable-stylesheets) | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
assert: { type: "css" }, | ||
loader: "css-loader", | ||
options: { | ||
exportType: "css-style-sheet", | ||
}, | ||
}, | ||
// For Sass/SCSS: | ||
// | ||
// { | ||
// assert: { type: "css" }, | ||
// rules: [ | ||
// { | ||
// loader: "css-loader", | ||
// options: { | ||
// exportType: "css-style-sheet", | ||
// // Other options | ||
// }, | ||
// }, | ||
// { | ||
// loader: "sass-loader", | ||
// options: { | ||
// // Other options | ||
// }, | ||
// }, | ||
// ], | ||
// }, | ||
], | ||
}, | ||
}; | ||
``` | ||
**src/index.js** | ||
```js | ||
// Example for Sass/SCSS: | ||
// import sheet from "./styles.scss" assert { type: "css" }; | ||
// Example for CSS modules: | ||
// import sheet, { myClass } from "./styles.scss" assert { type: "css" }; | ||
// Example for CSS: | ||
import sheet from "./styles.css" assert { type: "css" }; | ||
document.adoptedStyleSheets = [sheet]; | ||
shadowRoot.adoptedStyleSheets = [sheet]; | ||
``` | ||
For migration purposes, you can use the following configuration: | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
oneOf: [ | ||
{ | ||
assert: { type: "css" }, | ||
loader: "css-loader", | ||
options: { | ||
exportType: "css-style-sheet", | ||
// Other options | ||
}, | ||
}, | ||
{ | ||
use: [ | ||
"style-loader", | ||
{ | ||
loader: "css-loader", | ||
options: { | ||
// Other options | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
## Examples | ||
### Recommend | ||
For `production` builds it's recommended to extract the CSS from your bundle being able to use parallel loading of CSS/JS resources later on. | ||
This can be achieved by using the [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin), because it creates separate css files. | ||
For `development` mode (including `webpack-dev-server`) you can use [style-loader](https://github.com/webpack-contrib/style-loader), because it injects CSS into the DOM using multiple <style></style> and works faster. | ||
> **Note** | ||
> | ||
> Do not use `style-loader` and `mini-css-extract-plugin` together. | ||
**webpack.config.js** | ||
```js | ||
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); | ||
const devMode = process.env.NODE_ENV !== "production"; | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
// If you enable `experiments.css` or `experiments.futureDefaults`, please uncomment line below | ||
// type: "javascript/auto", | ||
test: /\.(sa|sc|c)ss$/i, | ||
use: [ | ||
devMode ? "style-loader" : MiniCssExtractPlugin.loader, | ||
"css-loader", | ||
"postcss-loader", | ||
"sass-loader", | ||
], | ||
}, | ||
], | ||
}, | ||
plugins: [].concat(devMode ? [] : [new MiniCssExtractPlugin()]), | ||
}; | ||
``` | ||
### Disable url resolving using the `/* webpackIgnore: true */` comment | ||
With the help of the `/* webpackIgnore: true */`comment, it is possible to disable sources handling for rules and for individual declarations. | ||
```css | ||
/* webpackIgnore: true */ | ||
@import url(./basic.css); | ||
@import /* webpackIgnore: true */ url(./imported.css); | ||
.class { | ||
/* Disabled url handling for the all urls in the 'background' declaration */ | ||
color: red; | ||
/* webpackIgnore: true */ | ||
background: url("./url/img.png"), url("./url/img.png"); | ||
} | ||
.class { | ||
/* Disabled url handling for the first url in the 'background' declaration */ | ||
color: red; | ||
background: | ||
/* webpackIgnore: true */ url("./url/img.png"), url("./url/img.png"); | ||
} | ||
.class { | ||
/* Disabled url handling for the second url in the 'background' declaration */ | ||
color: red; | ||
background: url("./url/img.png"), | ||
/* webpackIgnore: true */ url("./url/img.png"); | ||
} | ||
/* prettier-ignore */ | ||
.class { | ||
/* Disabled url handling for the second url in the 'background' declaration */ | ||
color: red; | ||
background: url("./url/img.png"), | ||
/* webpackIgnore: true */ | ||
url("./url/img.png"); | ||
} | ||
/* prettier-ignore */ | ||
.class { | ||
/* Disabled url handling for third and sixth urls in the 'background-image' declaration */ | ||
background-image: image-set( | ||
url(./url/img.png) 2x, | ||
url(./url/img.png) 3x, | ||
/* webpackIgnore: true */ url(./url/img.png) 4x, | ||
url(./url/img.png) 5x, | ||
url(./url/img.png) 6x, | ||
/* webpackIgnore: true */ | ||
url(./url/img.png) 7x | ||
); | ||
} | ||
``` | ||
### Assets | ||
The following `webpack.config.js` can load CSS files, embed small PNG/JPG/GIF/SVG images as well as fonts as [Data URLs](https://tools.ietf.org/html/rfc2397) and copy larger files to the output directory. | ||
**For webpack v5:** | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
use: ["style-loader", "css-loader"], | ||
}, | ||
{ | ||
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/i, | ||
// More information here https://webpack.js.org/guides/asset-modules/ | ||
type: "asset", | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
### Extract | ||
For production builds it's recommended to extract the CSS from your bundle being able to use parallel loading of CSS/JS resources later on. This can be achieved by using the [extract-text-webpack-plugin](https://github.com/webpack-contrib/extract-text-webpack-plugin) to extract the CSS when running in production mode. | ||
For production builds it's recommended to extract the CSS from your bundle being able to use parallel loading of CSS/JS resources later on. | ||
- This can be achieved by using the [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) to extract the CSS when running in production mode. | ||
- As an alternative, if seeking better development performance and css outputs that mimic production. [extract-css-chunks-webpack-plugin](https://github.com/faceyspacey/extract-css-chunks-webpack-plugin) offers a hot module reload friendly, extended version of mini-css-extract-plugin. HMR real CSS files in dev, works like mini-css in non-dev | ||
### Pure CSS, CSS modules and PostCSS | ||
When you have pure CSS (without CSS modules), CSS modules and PostCSS in your project you can use this setup: | ||
**webpack.config.js** | ||
```js | ||
const env = process.env.NODE_ENV | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
// For pure CSS - /\.css$/i, | ||
// For Sass/SCSS - /\.((c|sa|sc)ss)$/i, | ||
// For Less - /\.((c|le)ss)$/i, | ||
test: /\.((c|sa|sc)ss)$/i, | ||
use: [ | ||
"style-loader", | ||
{ | ||
loader: "css-loader", | ||
options: { | ||
// Run `postcss-loader` on each CSS `@import` and CSS modules/ICSS imports, do not forget that `sass-loader` compile non CSS `@import`'s into a single file | ||
// If you need run `sass-loader` and `postcss-loader` on each CSS `@import` please set it to `2` | ||
importLoaders: 1, | ||
}, | ||
}, | ||
{ | ||
loader: "postcss-loader", | ||
options: { plugins: () => [postcssPresetEnv({ stage: 0 })] }, | ||
}, | ||
// Can be `less-loader` | ||
{ | ||
loader: "sass-loader", | ||
}, | ||
], | ||
}, | ||
// For webpack v5 | ||
{ | ||
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/i, | ||
// More information here https://webpack.js.org/guides/asset-modules/ | ||
type: "asset", | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
const ExtractTextPlugin = require('extract-text-webpack-plugin') | ||
### Resolve unresolved URLs using an alias | ||
**index.css** | ||
```css | ||
.class { | ||
background: url(/assets/unresolved/img.png); | ||
} | ||
``` | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
@@ -483,92 +1883,170 @@ module: { | ||
{ | ||
test: /\.css$/, | ||
use: env === 'production' | ||
? ExtractTextPlugin.extract({ | ||
fallback: 'style-loader', | ||
use: [ 'css-loader' ] | ||
}) | ||
: [ 'style-loader', 'css-loader' ] | ||
test: /\.css$/i, | ||
use: ["style-loader", "css-loader"], | ||
}, | ||
] | ||
], | ||
}, | ||
plugins: env === 'production' | ||
? [ | ||
new ExtractTextPlugin({ | ||
filename: '[name].css' | ||
}) | ||
] | ||
: [] | ||
resolve: { | ||
alias: { | ||
"/assets/unresolved/img.png": path.resolve( | ||
__dirname, | ||
"assets/real-path-to-img/img.png" | ||
), | ||
}, | ||
}, | ||
}; | ||
``` | ||
### Named export with custom export names | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
loader: "css-loader", | ||
options: { | ||
modules: { | ||
namedExport: true, | ||
exportLocalsConvention: function (name) { | ||
return name.replace(/-/g, "_"); | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
### Separating `Interoperable CSS`-only and `CSS Module` features | ||
The following setup is an example of allowing `Interoperable CSS` features only (such as `:import` and `:export`) without using further `CSS Module` functionality by setting `mode` option for all files that do not match `*.module.scss` naming convention. This is for reference as having `ICSS` features applied to all files was default `css-loader` behavior before v4. | ||
Meanwhile all files matching `*.module.scss` are treated as `CSS Modules` in this example. | ||
An example case is assumed where a project requires canvas drawing variables to be synchronized with CSS - canvas drawing uses the same color (set by color name in JavaScript) as HTML background (set by class name in CSS). | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
// ... | ||
// -------- | ||
// SCSS ALL EXCEPT MODULES | ||
{ | ||
test: /\.scss$/i, | ||
exclude: /\.module\.scss$/i, | ||
use: [ | ||
{ | ||
loader: "style-loader", | ||
}, | ||
{ | ||
loader: "css-loader", | ||
options: { | ||
importLoaders: 1, | ||
modules: { | ||
mode: "icss", | ||
}, | ||
}, | ||
}, | ||
{ | ||
loader: "sass-loader", | ||
}, | ||
], | ||
}, | ||
// -------- | ||
// SCSS MODULES | ||
{ | ||
test: /\.module\.scss$/i, | ||
use: [ | ||
{ | ||
loader: "style-loader", | ||
}, | ||
{ | ||
loader: "css-loader", | ||
options: { | ||
importLoaders: 1, | ||
modules: { | ||
mode: "local", | ||
}, | ||
}, | ||
}, | ||
{ | ||
loader: "sass-loader", | ||
}, | ||
], | ||
}, | ||
// -------- | ||
// ... | ||
], | ||
}, | ||
}; | ||
``` | ||
**variables.scss** | ||
File treated as `ICSS`-only. | ||
```scss | ||
$colorBackground: red; | ||
:export { | ||
colorBackgroundCanvas: $colorBackground; | ||
} | ||
``` | ||
<h2 align="center">Maintainers</h2> | ||
**Component.module.scss** | ||
<table> | ||
<tbody> | ||
<tr> | ||
<td align="center"> | ||
<img width="150" height="150" | ||
src="https://github.com/bebraw.png?v=3&s=150"> | ||
</br> | ||
<a href="https://github.com/bebraw">Juho Vepsäläinen</a> | ||
</td> | ||
<td align="center"> | ||
<img width="150" height="150" | ||
src="https://github.com/d3viant0ne.png?v=3&s=150"> | ||
</br> | ||
<a href="https://github.com/d3viant0ne">Joshua Wiens</a> | ||
</td> | ||
<td align="center"> | ||
<img width="150" height="150" | ||
src="https://github.com/SpaceK33z.png?v=3&s=150"> | ||
</br> | ||
<a href="https://github.com/SpaceK33z">Kees Kluskens</a> | ||
</td> | ||
<td align="center"> | ||
<img width="150" height="150" | ||
src="https://github.com/TheLarkInn.png?v=3&s=150"> | ||
</br> | ||
<a href="https://github.com/TheLarkInn">Sean Larkin</a> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td align="center"> | ||
<img width="150" height="150" | ||
src="https://github.com/michael-ciniawsky.png?v=3&s=150"> | ||
</br> | ||
<a href="https://github.com/michael-ciniawsky">Michael Ciniawsky</a> | ||
</td> | ||
<td align="center"> | ||
<img width="150" height="150" | ||
src="https://github.com/evilebottnawi.png?v=3&s=150"> | ||
</br> | ||
<a href="https://github.com/evilebottnawi">Evilebot Tnawi</a> | ||
</td> | ||
<td align="center"> | ||
<img width="150" height="150" | ||
src="https://github.com/joscha.png?v=3&s=150"> | ||
</br> | ||
<a href="https://github.com/joscha">Joscha Feth</a> | ||
</td> | ||
</tr> | ||
<tbody> | ||
</table> | ||
File treated as `CSS Module`. | ||
```scss | ||
@import "variables.scss"; | ||
.componentClass { | ||
background-color: $colorBackground; | ||
} | ||
``` | ||
**Component.jsx** | ||
Using both `CSS Module` functionality as well as SCSS variables directly in JavaScript. | ||
```jsx | ||
import svars from "variables.scss"; | ||
import styles from "Component.module.scss"; | ||
// Render DOM with CSS modules class name | ||
// <div className={styles.componentClass}> | ||
// <canvas ref={mountsCanvas}/> | ||
// </div> | ||
// Somewhere in JavaScript canvas drawing code use the variable directly | ||
// const ctx = mountsCanvas.current.getContext('2d',{alpha: false}); | ||
ctx.fillStyle = `${svars.colorBackgroundCanvas}`; | ||
``` | ||
## Contributing | ||
Please take a moment to read our contributing guidelines if you haven't yet done so. | ||
[CONTRIBUTING](./.github/CONTRIBUTING.md) | ||
## License | ||
[MIT](./LICENSE) | ||
[npm]: https://img.shields.io/npm/v/css-loader.svg | ||
[npm-url]: https://npmjs.com/package/css-loader | ||
[node]: https://img.shields.io/node/v/css-loader.svg | ||
[node-url]: https://nodejs.org | ||
[deps]: https://david-dm.org/webpack-contrib/css-loader.svg | ||
[deps-url]: https://david-dm.org/webpack-contrib/css-loader | ||
[tests]: http://img.shields.io/travis/webpack-contrib/css-loader.svg | ||
[tests-url]: https://travis-ci.org/webpack-contrib/css-loader | ||
[tests]: https://github.com/webpack-contrib/css-loader/workflows/css-loader/badge.svg | ||
[tests-url]: https://github.com/webpack-contrib/css-loader/actions | ||
[cover]: https://codecov.io/gh/webpack-contrib/css-loader/branch/master/graph/badge.svg | ||
[cover-url]: https://codecov.io/gh/webpack-contrib/css-loader | ||
[chat]: https://badges.gitter.im/webpack/webpack.svg | ||
[chat-url]: https://gitter.im/webpack/webpack | ||
[discussion]: https://img.shields.io/github/discussions/webpack/webpack | ||
[discussion-url]: https://github.com/webpack/webpack/discussions | ||
[size]: https://packagephobia.now.sh/badge?p=css-loader | ||
[size-url]: https://packagephobia.now.sh/result?p=css-loader |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
131093
190.55%9
-35.71%2272
265.27%0
-100%2043
261.59%37
516.67%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated
Updated