{"_id":"css-loader-1","_rev":"2856188","name":"css-loader-1","description":"css loader module for webpack","dist-tags":{"latest":"2.0.0"},"maintainers":[{"name":"sorrycc","email":""}],"time":{"modified":"2022-09-06T16:45:00.000Z","created":"2019-05-22T04:31:09.101Z","2.0.0":"2019-05-22T04:31:09.101Z"},"users":{},"author":{"name":"Tobias Koppers @sokra"},"repository":{"type":"git","url":"git+https://github.com/webpack-contrib/css-loader.git"},"versions":{"2.0.0":{"name":"css-loader-1","version":"2.0.0","author":{"name":"Tobias Koppers @sokra"},"license":"MIT","description":"css loader module for webpack","engines":{"node":">= 6.9.0 <7.0.0 || >= 8.9.0"},"dependencies":{"babel-code-frame":"^6.26.0","css-selector-tokenizer":"^0.7.0","icss-utils":"^2.1.0","loader-utils":"^1.0.2","lodash.camelcase":"^4.3.0","postcss":"^6.0.23","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"},"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"},"peerDependencies":{"webpack":"^4.0.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":{"type":"git","url":"git+https://github.com/webpack-contrib/css-loader.git"},"bugs":{"url":"https://github.com/webpack-contrib/css-loader/issues"},"gitHead":"aebc0625c53f283dfebe79c8d15499d8cbb1d011","_id":"css-loader-1@2.0.0","_nodeVersion":"10.13.0","_npmVersion":"6.8.0","dist":{"shasum":"4dec481134dc6df3c95a769fbec440138c418fc2","size":12747,"noattachment":false,"key":"/css-loader-1/-/css-loader-1-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/css-loader-1/download/css-loader-1-2.0.0.tgz"},"maintainers":[{"name":"sorrycc","email":""}],"_npmUser":{"name":"sorrycc","email":"sorrycc@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/css-loader-1_2.0.0_1558499468973_0.07381074855902714"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-20T08:04:54.206Z","publish_time":1558499469101,"_cnpm_publish_time":1558499469101}},"readme":"[![npm][npm]][npm-url]\n[![node][node]][node-url]\n[![deps][deps]][deps-url]\n[![tests][tests]][tests-url]\n[![coverage][cover]][cover-url]\n[![chat][chat]][chat-url]\n\n<div align=\"center\">\n  <img width=\"180\" height=\"180\" vspace=\"20\"\n    src=\"https://cdn.worldvectorlogo.com/logos/css-3.svg\">\n  <a href=\"https://github.com/webpack/webpack\">\n    <img width=\"200\" height=\"200\"\n      src=\"https://webpack.js.org/assets/icon-square-big.svg\">\n  </a>\n  <h1>CSS Loader</h1>\n</div>\n\n<h2 align=\"center\">Install</h2>\n\n```bash\nnpm install --save-dev css-loader\n```\n\n<h2 align=\"center\">Usage</h2>\n\nThe `css-loader` interprets `@import` and `url()` like `import/require()`\nand will resolve them.\n\nGood loaders for requiring your assets are the [file-loader](https://github.com/webpack/file-loader)\nand 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)).\n\n**file.js**\n```js\nimport css from 'file.css';\n```\n\n**webpack.config.js**\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.css$/,\n        use: [ 'style-loader', 'css-loader' ]\n      }\n    ]\n  }\n}\n```\n\n### `toString`\n\nYou can also use the css-loader results directly as string, such as in Angular's component style.\n\n**webpack.config.js**\n```js\n{\n   test: /\\.css$/,\n   use: [\n     'to-string-loader',\n     'css-loader'\n   ]\n}\n```\n\nor\n\n```js\nconst css = require('./test.css').toString();\n\nconsole.log(css); // {String}\n```\n\nIf there are SourceMaps, they will also be included in the result string.\n\nIf, for one reason or another, you need to extract CSS as a\nplain string resource (i.e. not wrapped in a JS module) you\nmight want to check out the [extract-loader](https://github.com/peerigon/extract-loader).\nIt's useful when you, for instance, need to post process the CSS as a string.\n\n**webpack.config.js**\n```js\n{\n   test: /\\.css$/,\n   use: [\n     'handlebars-loader', // handlebars loader expects raw resource string\n     'extract-loader',\n     'css-loader'\n   ]\n}\n```\n\n<h2 align=\"center\">Options</h2>\n\n|Name|Type|Default|Description|\n|:--:|:--:|:-----:|:----------|\n|**[`url`](#url)**|`{Boolean}`|`true`| Enable/Disable `url()` handling|\n|**[`import`](#import)** |`{Boolean}`|`true`| Enable/Disable @import handling|\n|**[`modules`](#modules)**|`{Boolean}`|`false`|Enable/Disable CSS Modules|\n|**[`localIdentName`](#localidentname)**|`{String}`|`[hash:base64]`|Configure the generated ident|\n|**[`sourceMap`](#sourcemap)**|`{Boolean}`|`false`|Enable/Disable Sourcemaps|\n|**[`camelCase`](#camelcase)**|`{Boolean\\|String}`|`false`|Export Classnames in CamelCase|\n|**[`importLoaders`](#importloaders)**|`{Number}`|`0`|Number of loaders applied before CSS loader|\n\n### `url`\n\nTo disable `url()` resolving by `css-loader` set the option to `false`.\n\nTo be compatible with existing css files (if not in CSS Module mode).\n\n```\nurl(image.png) => require('./image.png')\nurl(~module/image.png) => require('module/image.png')\n```\n\n### `import`\n\nTo disable `@import` resolving by `css-loader` set the option to `false`\n\n```css\n@import url('https://fonts.googleapis.com/css?family=Roboto');\n```\n\n> _⚠️ Use with caution, since this disables resolving for **all** `@import`s, including css modules `composes: xxx from 'path/to/file.css'` feature._\n\n### [`modules`](https://github.com/css-modules/css-modules)\n\nThe query parameter `modules` enables the **CSS Modules** spec.\n\nThis enables local scoped CSS by default. (You can switch it off with `:global(...)` or `:global` for selectors and/or rules.).\n\n#### `Scope`\n\nBy default CSS exports all classnames into a global selector scope. Styles can be locally scoped to avoid globally scoping styles.\n\nThe syntax `:local(.className)` can be used to declare `className` in the local scope. The local identifiers are exported by the module.\n\nWith `: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.\n\nThe loader replaces local selectors with unique identifiers. The choosen unique identifiers are exported by the module.\n\n```css\n:local(.className) { background: red; }\n:local .className { color: green; }\n:local(.className .subClass) { color: green; }\n:local .className .subClass :global(.global-class-name) { color: blue; }\n```\n\n```css\n._23_aKvs-b8bW2Vg3fwHozO { background: red; }\n._23_aKvs-b8bW2Vg3fwHozO { color: green; }\n._23_aKvs-b8bW2Vg3fwHozO ._13LGdX8RMStbBE9w-t0gZ1 { color: green; }\n._23_aKvs-b8bW2Vg3fwHozO ._13LGdX8RMStbBE9w-t0gZ1 .global-class-name { color: blue; }\n```\n\n> ℹ️ Identifiers are exported\n\n```js\nexports.locals = {\n  className: '_23_aKvs-b8bW2Vg3fwHozO',\n  subClass: '_13LGdX8RMStbBE9w-t0gZ1'\n}\n```\n\nCamelCase is recommended for local selectors. They are easier to use in the within the imported JS module.\n\n`url()` URLs in block scoped (`:local .abc`) rules behave like requests in modules.\n\n```\nfile.png => ./file.png\n~module/file.png => module/file.png\n```\n\nYou can use `:local(#someId)`, but this is not recommended. Use classes instead of ids.\n\n#### `Composing`\n\nWhen declaring a local classname you can compose a local class from another local classname.\n\n```css\n:local(.className) {\n  background: red;\n  color: yellow;\n}\n\n:local(.subClass) {\n  composes: className;\n  background: blue;\n}\n```\n\nThis doesn't result in any change to the CSS itself but exports multiple classnames.\n\n```js\nexports.locals = {\n  className: '_23_aKvs-b8bW2Vg3fwHozO',\n  subClass: '_13LGdX8RMStbBE9w-t0gZ1 _23_aKvs-b8bW2Vg3fwHozO'\n}\n```\n\n``` css\n._23_aKvs-b8bW2Vg3fwHozO {\n  background: red;\n  color: yellow;\n}\n\n._13LGdX8RMStbBE9w-t0gZ1 {\n  background: blue;\n}\n```\n\n#### `Importing`\n\nTo import a local classname from another module.\n\n```css\n:local(.continueButton) {\n  composes: button from 'library/button.css';\n  background: red;\n}\n```\n\n```css\n:local(.nameEdit) {\n  composes: edit highlight from './edit.css';\n  background: red;\n}\n```\n\nTo import from multiple modules use multiple `composes:` rules.\n\n```css\n:local(.className) {\n  composes: edit hightlight from './edit.css';\n  composes: button from 'module/button.css';\n  composes: classFromThisModule;\n  background: red;\n}\n```\n\n### `localIdentName`\n\nYou can configure the generated ident with the `localIdentName` query parameter. See [loader-utils's documentation](https://github.com/webpack/loader-utils#interpolatename) for more information on options.\n\n **webpack.config.js**\n```js\n{\n  test: /\\.css$/,\n  use: [\n    {\n      loader: 'css-loader',\n      options: {\n        modules: true,\n        localIdentName: '[path][name]__[local]--[hash:base64:5]'\n      }\n    }\n  ]\n}\n```\n\nYou 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).\n\n**webpack.config.js**\n```js\n{\n  loader: 'css-loader',\n  options: {\n    modules: true,\n    localIdentName: '[path][name]__[local]--[hash:base64:5]',\n    getLocalIdent: (context, localIdentName, localName, options) => {\n      return 'whatever_random_class_name'\n    }\n  }\n}\n```\n\n> ℹ️ 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.\n\n### `sourceMap`\n\nTo include source maps set the `sourceMap` option.\n\nI. e. the extract-text-webpack-plugin can handle them.\n\nThey 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.\n\n**webpack.config.js**\n```js\n{\n  loader: 'css-loader',\n  options: {\n    sourceMap: true\n  }\n}\n```\n\n### `camelCase`\n\nBy 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.\n\n|Name|Type|Description|\n|:--:|:--:|:----------|\n|**`true`**|`{Boolean}`|Class names will be camelized|\n|**`'dashes'`**|`{String}`|Only dashes in class names will be camelized|\n|**`'only'`** |`{String}`|Introduced in `0.27.1`. Class names will be camelized, the original class name will be removed from the locals|\n|**`'dashesOnly'`**|`{String}`|Introduced in `0.27.1`. Dashes in class names will be camelized, the original class name will be removed from the locals|\n\n**file.css**\n```css\n.class-name {}\n```\n\n**file.js**\n```js\nimport { className } from 'file.css';\n```\n\n**webpack.config.js**\n```js\n{\n  loader: 'css-loader',\n  options: {\n    camelCase: true\n  }\n}\n```\n\n### `importLoaders`\n\nThe query parameter `importLoaders` allows to configure how many loaders before `css-loader` should be applied to `@import`ed resources.\n\n**webpack.config.js**\n```js\n{\n  test: /\\.css$/,\n  use: [\n    'style-loader',\n    {\n      loader: 'css-loader',\n      options: {\n        importLoaders: 2 // 0 => no loaders (default); 1 => postcss-loader; 2 => postcss-loader, sass-loader\n      }\n    },\n    'postcss-loader',\n    'sass-loader'\n  ]\n}\n```\n\nThis may change in the future, when the module system (i. e. webpack) supports loader matching by origin.\n\n<h2 align=\"center\">Examples</h2>\n\n### Assets\n\nThe 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.\n\n**webpack.config.js**\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.css$/,\n        use: [ 'style-loader', 'css-loader' ]\n      },\n      {\n        test: /\\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,\n        loader: 'url-loader',\n        options: {\n          limit: 10000\n        }\n      }\n    ]\n  }\n}\n```\n\n### Extract\n\nFor production builds it's recommended to extract the CSS from your bundle being able to use parallel loading of CSS/JS resources later on. \nThis 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.\n\n<h2 align=\"center\">Maintainers</h2>\n\n<table>\n  <tbody>\n    <tr>\n      <td align=\"center\">\n        <img width=\"150\" height=\"150\"\n        src=\"https://github.com/bebraw.png?v=3&s=150\">\n        </br>\n        <a href=\"https://github.com/bebraw\">Juho Vepsäläinen</a>\n      </td>\n      <td align=\"center\">\n        <img width=\"150\" height=\"150\"\n        src=\"https://github.com/d3viant0ne.png?v=3&s=150\">\n        </br>\n        <a href=\"https://github.com/d3viant0ne\">Joshua Wiens</a>\n      </td>\n      <td align=\"center\">\n        <img width=\"150\" height=\"150\"\n        src=\"https://github.com/SpaceK33z.png?v=3&s=150\">\n        </br>\n        <a href=\"https://github.com/SpaceK33z\">Kees Kluskens</a>\n      </td>\n      <td align=\"center\">\n        <img width=\"150\" height=\"150\"\n        src=\"https://github.com/TheLarkInn.png?v=3&s=150\">\n        </br>\n        <a href=\"https://github.com/TheLarkInn\">Sean Larkin</a>\n      </td>\n    </tr>\n    <tr>\n      <td align=\"center\">\n        <img width=\"150\" height=\"150\"\n        src=\"https://github.com/michael-ciniawsky.png?v=3&s=150\">\n        </br>\n        <a href=\"https://github.com/michael-ciniawsky\">Michael Ciniawsky</a>\n      </td>\n      <td align=\"center\">\n        <img width=\"150\" height=\"150\"\n        src=\"https://github.com/evilebottnawi.png?v=3&s=150\">\n        </br>\n        <a href=\"https://github.com/evilebottnawi\">Evilebot Tnawi</a>\n      </td>\n      <td align=\"center\">\n        <img width=\"150\" height=\"150\"\n        src=\"https://github.com/joscha.png?v=3&s=150\">\n        </br>\n        <a href=\"https://github.com/joscha\">Joscha Feth</a>\n      </td>\n    </tr>\n  <tbody>\n</table>\n\n\n[npm]: https://img.shields.io/npm/v/css-loader.svg\n[npm-url]: https://npmjs.com/package/css-loader\n\n[node]: https://img.shields.io/node/v/css-loader.svg\n[node-url]: https://nodejs.org\n\n[deps]: https://david-dm.org/webpack-contrib/css-loader.svg\n[deps-url]: https://david-dm.org/webpack-contrib/css-loader\n\n[tests]: http://img.shields.io/travis/webpack-contrib/css-loader.svg\n[tests-url]: https://travis-ci.org/webpack-contrib/css-loader\n\n[cover]: https://codecov.io/gh/webpack-contrib/css-loader/branch/master/graph/badge.svg\n[cover-url]: https://codecov.io/gh/webpack-contrib/css-loader\n\n[chat]: https://badges.gitter.im/webpack/webpack.svg\n[chat-url]: https://gitter.im/webpack/webpack\n","_attachments":{},"homepage":"https://github.com/webpack-contrib/css-loader","bugs":{"url":"https://github.com/webpack-contrib/css-loader/issues"},"license":"MIT"}