UNPKG

motion

Version:

motion - moving development forward

74 lines (73 loc) 10.2 kB
{ "_args": [ [ "css-loader@https://registry.npmjs.org/css-loader/-/css-loader-0.23.1.tgz", "/Users/nw/flint/packages/flint" ] ], "_from": "css-loader@0.23.1", "_id": "css-loader@0.23.1", "_inCache": true, "_location": "/css-loader", "_phantomChildren": {}, "_requested": { "name": "css-loader", "raw": "css-loader@https://registry.npmjs.org/css-loader/-/css-loader-0.23.1.tgz", "rawSpec": "https://registry.npmjs.org/css-loader/-/css-loader-0.23.1.tgz", "scope": null, "spec": "https://registry.npmjs.org/css-loader/-/css-loader-0.23.1.tgz", "type": "remote" }, "_requiredBy": [ "/" ], "_resolved": "https://registry.npmjs.org/css-loader/-/css-loader-0.23.1.tgz", "_shasum": "9fa23f2b5c0965235910ad5ecef3b8a36390fe50", "_shrinkwrap": null, "_spec": "css-loader@https://registry.npmjs.org/css-loader/-/css-loader-0.23.1.tgz", "_where": "/Users/nw/flint/packages/flint", "author": { "name": "Tobias Koppers @sokra" }, "bugs": { "url": "https://github.com/webpack/css-loader/issues" }, "dependencies": { "css-selector-tokenizer": "^0.5.1", "cssnano": ">=2.6.1 <4", "loader-utils": "~0.2.2", "lodash.camelcase": "^3.0.1", "object-assign": "^4.0.1", "postcss": "^5.0.6", "postcss-modules-extract-imports": "^1.0.0", "postcss-modules-local-by-default": "^1.0.1", "postcss-modules-scope": "^1.0.0", "postcss-modules-values": "^1.1.0", "source-list-map": "^0.1.4" }, "description": "css loader module for webpack", "devDependencies": { "codecov.io": "^0.1.2", "coveralls": "^2.11.2", "istanbul": "^0.3.13", "mocha": "^2.2.4", "should": "^7.0.1" }, "homepage": "https://github.com/webpack/css-loader#readme", "license": "MIT", "name": "css-loader", "optionalDependencies": {}, "readme": "# css loader for webpack\r\n\r\n## installation\r\n\r\n`npm install css-loader --save-dev`\r\n\r\n## Usage\r\n\r\n[Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html)\r\n\r\n``` javascript\r\nvar css = require(\"css!./file.css\");\r\n// => returns css code from file.css, resolves imports and url(...)\r\n```\r\n\r\n`@import` and `url(...)` are interpreted like `require()` and will be resolved by the css-loader.\r\nGood loaders for requiring your assets are the [file-loader](https://github.com/webpack/file-loader)\r\nand the [url-loader](https://github.com/webpack/url-loader) which you should specify in your config (see below).\r\n\r\nTo be compatible with existing css files (if not in CSS Module mode):\r\n* `url(image.png)` => `require(\"./image.png\")`\r\n* `url(~module/image.png)` => `require(\"module/image.png\")`\r\n\r\n### Example config\r\n\r\nThis webpack config can load css files, embed small png images as Data Urls and jpg images as files.\r\n\r\n``` javascript\r\nmodule.exports = {\r\n module: {\r\n loaders: [\r\n { test: /\\.css$/, loader: \"style-loader!css-loader\" },\r\n { test: /\\.png$/, loader: \"url-loader?limit=100000\" },\r\n { test: /\\.jpg$/, loader: \"file-loader\" }\r\n ]\r\n }\r\n};\r\n```\r\n\r\n### 'Root-relative' urls\r\n\r\nFor urls that start with a `/`, the default behavior is to not translate them:\r\n* `url(/image.png)` => `url(/image.png)`\r\n\r\nIf a `root` query parameter is set, however, it will be prepended to the url\r\nand then translated:\r\n\r\nWith a config like:\r\n\r\n``` javascript\r\n loaders: [\r\n { test: /\\.css$/, loader: \"style-loader!css-loader?root=.\" },\r\n ...\r\n ]\r\n```\r\n\r\nThe result is:\r\n\r\n* `url(/image.png)` => `require(\"./image.png\")`\r\n\r\nUsing 'Root-relative' urls is not recommended. You should only use it for legacy CSS files.\r\n\r\n### Local scope\r\n\r\nBy default CSS exports all class names into a global selector scope. This is a feature which offer a local selector scope.\r\n\r\nThe syntax `:local(.className)` can be used to declare `className` in the local scope. The local identifiers are exported by the module.\r\n\r\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.\r\n\r\nThe loader replaces local selectors with unique identifiers. The choosen unique identifiers are exported by the module.\r\n\r\nExample:\r\n\r\n``` css\r\n:local(.className) { background: red; }\r\n:local .className { color: green; }\r\n:local(.className .subClass) { color: green; }\r\n:local .className .subClass :global(.global-class-name) { color: blue; }\r\n```\r\n\r\nis transformed to\r\n\r\n``` css\r\n._23_aKvs-b8bW2Vg3fwHozO { background: red; }\r\n._23_aKvs-b8bW2Vg3fwHozO { color: green; }\r\n._23_aKvs-b8bW2Vg3fwHozO ._13LGdX8RMStbBE9w-t0gZ1 { color: green; }\r\n._23_aKvs-b8bW2Vg3fwHozO ._13LGdX8RMStbBE9w-t0gZ1 .global-class-name { color: blue; }\r\n```\r\n\r\nand the identifiers are exported:\r\n\r\n``` js\r\nexports.locals = {\r\n className: \"_23_aKvs-b8bW2Vg3fwHozO\",\r\n subClass: \"_13LGdX8RMStbBE9w-t0gZ1\"\r\n}\r\n```\r\n\r\nCamelcasing is recommended for local selectors. They are easier to use in the importing javascript module.\r\n\r\n`url(...)` URLs in block scoped (`:local .abc`) rules behave like requests in modules:\r\n * `./file.png` instead of `file.png`\r\n * `module/file.png` instead of `~module/file.png`\r\n\r\n\r\nYou can use `:local(#someId)`, but this is not recommended. Use classes instead of ids.\r\n\r\nYou can configure the generated ident with the `localIdentName` query parameter (default `[hash:base64]`). Example: `css-loader?localIdentName=[path][name]---[local]---[hash:base64:5]` for easier debugging.\r\n\r\nNote: 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.\r\n\r\n### CSS Modules\r\n\r\nSee [CSS Modules](https://github.com/css-modules/css-modules).\r\n\r\nThe query parameter `modules` enables the **CSS Modules** spec. (`css-loader?modules`)\r\n\r\nThis enables Local scoped CSS by default. (You can switch it off with `:global(...)` or `:global` for selectors and/or rules.)\r\n\r\n### Composing CSS classes\r\n\r\nWhen declaring a local class name you can compose a local class from another local class name.\r\n\r\n``` css\r\n:local(.className) {\r\n background: red;\r\n color: yellow;\r\n}\r\n\r\n:local(.subClass) {\r\n composes: className;\r\n background: blue;\r\n}\r\n```\r\n\r\nThis doesn't result in any change to the CSS itself but exports multiple class names:\r\n\r\n``` js\r\nexports.locals = {\r\n className: \"_23_aKvs-b8bW2Vg3fwHozO\",\r\n subClass: \"_13LGdX8RMStbBE9w-t0gZ1 _23_aKvs-b8bW2Vg3fwHozO\"\r\n}\r\n```\r\n\r\nand CSS is transformed to:\r\n\r\n``` css\r\n._23_aKvs-b8bW2Vg3fwHozO {\r\n background: red;\r\n color: yellow;\r\n}\r\n\r\n._13LGdX8RMStbBE9w-t0gZ1 {\r\n background: blue;\r\n}\r\n```\r\n\r\n### Importing local class names\r\n\r\nTo import a local class name from another module:\r\n\r\n``` css\r\n:local(.continueButton) {\r\n composes: button from \"library/button.css\";\r\n background: red;\r\n}\r\n```\r\n\r\n``` css\r\n:local(.nameEdit) {\r\n composes: edit highlight from \"./edit.css\";\r\n background: red;\r\n}\r\n```\r\n\r\nTo import from multiple modules use multiple `composes:` rules.\r\n\r\n``` css\r\n:local(.className) {\r\n composes: edit hightlight from \"./edit.css\";\r\n composes: button from \"module/button.css\";\r\n composes: classFromThisModule;\r\n background: red;\r\n}\r\n```\r\n\r\n### SourceMaps\r\n\r\nTo include SourceMaps set the `sourceMap` query param.\r\n\r\n`require(\"css-loader?sourceMap!./file.css\")`\r\n\r\nI. e. the extract-text-webpack-plugin can handle them.\r\n\r\nThey are not enabled by default because they expose a runtime overhead and increase in bundle size (JS SourceMap do not). In addition to that relative paths are buggy and you need to use an absolute public path which include the server url.\r\n\r\n### importing and chained loaders\r\n\r\nThe query parameter `importLoaders` allow to configure which loaders should be applied to `@import`ed resources.\r\n\r\n`importLoaders` (int): That many loaders after the css-loader are used to import resources.\r\n\r\nExamples:\r\n\r\n``` js\r\nrequire(\"style-loader!css-loader?importLoaders=1!autoprefixer-loader!...\")\r\n// => imported resources are handled this way:\r\nrequire(\"css-loader?importLoaders=1!autoprefixer-loader!...\")\r\n\r\nrequire(\"style-loader!css-loader!stylus-loader!...\")\r\n// => imported resources are handled this way:\r\nrequire(\"css-loader!...\")\r\n```\r\n\r\nThis may change in the future, when the module system (i. e. webpack) supports loader matching by origin.\r\n\r\n### Minification\r\n\r\nBy default the css-loader minimizes the css if specified by the module system.\r\n\r\nIn some cases the minification is destructive to the css, so you can provide some options to it. cssnano is used for minification and you find a [list of options here](http://cssnano.co/options/). Just provide them as query parameter: i. e. `require(\"css-loader?-autoprefixer\")` to disable removing of deprecated vendor prefixes.\r\n\r\nYou can also disable or enforce minification with the `minimize` query parameter.\r\n\r\n`require(\"css-loader?minimize!./file.css\")` (enforced)\r\n\r\n`require(\"css-loader?-minimize!./file.css\")` (disabled)\r\n\r\n### Disable behavior\r\n\r\n`css-loader?-url` disables `url(...)` handling.\r\n\r\n`css-loader?-import` disables `@import` handling.\r\n\r\n## License\r\n\r\nMIT (http://www.opensource.org/licenses/mit-license.php)\r\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git+ssh://git@github.com/webpack/css-loader.git" }, "scripts": { "cover": "istanbul cover node_modules/mocha/bin/_mocha", "publish-patch": "mocha && npm version patch && git push && git push --tags && npm publish", "test": "mocha", "travis": "npm run cover -- --report lcovonly" }, "version": "0.23.1" }