{"name":"css-hot-loader","version":"1.4.0","description":"css hot reload work with extract-text-webpack-plugin","main":"index.js","scripts":{"pub":"npm version patch && npm publish && git push origin && git push origin --tags","cov":"jest --collectCoverageFrom='[\"*.js\"]' --coverage","ci":"npm run cov && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js","test":"jest"},"files":["loader.js","hotModuleReplacement.js","index.js"],"homepage":"http://git.shepherdwind.com/css-hot-loader/","repository":{"type":"git","url":"git://github.com/shepherdwind/css-hot-loader.git"},"author":{"name":"shepherdwind"},"license":"ISC","dependencies":{"loader-utils":"^1.1.0","lodash":"^4.17.5","normalize-url":"^1.9.1"},"devDependencies":{"coveralls":"^2.13.1","jest":"^20.0.4","strict-uri-encode":"^2.0.0"},"gitHead":"0a1be904c9e2d9ac23079f739606e99933539f64","bugs":{"url":"https://github.com/shepherdwind/css-hot-loader/issues"},"_id":"css-hot-loader@1.4.0","_npmVersion":"5.6.0","_nodeVersion":"8.11.2","_npmUser":{"name":"shepherdwind","email":"eward.song@gmail.com"},"dist":{"integrity":"sha512-OZ+wB1j0j3IDsWuaYZqJeQBTNUa+uyRzMWs7Tm5kwObnGqi+63V1KmGTfi0WGBHyhjtg9wiOqakpkXaXYpyZVw==","shasum":"170e8b4bf0708a9f5cfc289e8ee0c268ab9a41bb","tarball":"http://registry-npm.ywwl.com/css-hot-loader/download/css-hot-loader-1.4.0.tgz","fileCount":7,"unpackedSize":12009,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbRaX+CRA9TVsSAnZWagAAgxQP/3ccbDUPFaMKX3ey0idZ\nB7TiI1KPIwILEmx8zVqJKj98RD0XC9hgjrNiZ9YTQRQ2SXPEBzfCkHQeEBxF\nbP1mmHazNlhpw7M0egEYTSGfNS9FuKP+vSSx7IeHRr2xiqYyotNXJxmripIo\nsum5Nor6OB7trktC/W69gdZ0YddgM55YGecKa2eenWELff8zmo/i08AfIQ1v\nZCQAm3+Fae5qckeigdRqESTjtaqf4NUOUqLDnpceeZduTWq9Ol6wDOSwyWVo\nWzoDP13VahSoaKSCDGP7qbgyOHOmQG+QM627fMmGY+gJ5OTpRJZzKYUyIgZR\nCkl3/zc0kpGDMDz3D788/rC9Jn0sPlQuJN1svSMP59Mt7+9nMvapYI1wmp83\nZbwUkulhFRBU6y0Gldi/2pA8/c409Z4A1Nvo5qlPerxgMo5Bg+5Jk0rwCEBE\nrobhyNK+R4C6CMyb+08zVANTj0KpNRuIVfhtSpB3Vm5E9DqOvw/DAryFoQXH\n1fgiL83x2AX1v/dLcUb52JFVapxH/rCZpTWleeyuCRTowsTgdzoqHqtXlooP\nAyUjFLIDqn8WE3XLhvff9CqhSJcuZDg+D82ZCLOmPjV7xAw6/e3rRVNGVIXX\ngT1Bb3KwXpcxqAgGigjRDD+IlE/4VVxlCFjSbPB5FNKyWeFnYuvVxPACY/Bs\nploE\r\n=vjNF\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHQcnpn1Gcg5eY1Ydw7wr0wxxu56mcYa1AiA51Srr3/QAiEApeqDim7RxolzfP+67kOJZc2dclau+bt6NTm4EEQmpnw="}],"size":4918,"noattachment":false,"key":"/css-hot-loader/-/css-hot-loader-1.4.0.tgz"},"maintainers":[{"name":"shepherdwind","email":"eward.song@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/css-hot-loader_1.4.0_1531291134207_0.8843636029878164"},"_hasShrinkwrap":false,"readme":"### CSS Hot Loader\n\n[![build status][travis-image]][travis-url]\n[![Test coverage][coveralls-image]][coveralls-url]\n[![NPM version][npm-image]][npm-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: http://img.shields.io/npm/v/css-hot-loader.svg?style=flat-square\n[npm-url]: http://npmjs.org/package/css-hot-loader\n[download-image]: https://img.shields.io/npm/dm/css-hot-loader.svg?style=flat-square\n[download-url]: https://npmjs.org/package/css-hot-loader\n[travis-image]: https://img.shields.io/travis/shepherdwind/css-hot-loader.svg?style=flat-square\n[travis-url]: https://travis-ci.org/shepherdwind/css-hot-loader\n[coveralls-image]: https://img.shields.io/coveralls/shepherdwind/css-hot-loader.svg?style=flat-square\n[coveralls-url]: https://coveralls.io/r/shepherdwind/css-hot-loader?branch=master\n\nThis is a css hot loader, which support hot module replacement for an extracted css file.\n\n### Why we need css hot loader\n\nIn most cases, we can realize css hot reload by [style-loader](https://github.com/webpack/style-loader) . But style-loader need inject style tag into document, Before js ready, the web page will have no any style. That is not good experience.\n\nAlso, a lots of people thought about that, How can realize hot reload with\nextract-text-webpack-plugin. For example [#30](https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/30) , [#!89](https://github.com/webpack-contrib/extract-text-webpack-plugin/pull/89).\n\nSo I wrote this loader, which supports hot module replacement for an extracted css file.\n\n### Install\n\nFirst install package from npm\n\n```sh\n$ npm install css-hot-loader --save-dev\n```\n\nThen config webpack.config.js\n\n```javascript\nmodule: {\n  rules: [\n    {\n      test: /\\.css/,\n      use: [\n        'css-hot-loader',\n        MiniCssExtractPlugin.loader,\n        'css-loader',\n      ],\n    },\n  ] // end rules\n},\n```\n\nThere is an issue to work with webpack4 [#37](https://github.com/shepherdwind/css-hot-loader/issues/37).\nPlease use [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) to replace extract-text-webpack-plugin.\n\n### Attention\n\nThis plugin require the output css file name static. If output file name depend\non css content, for example `'bundle.[name].[contenthash].css'`, HMR reload will\nfail, more detail refer to [#21](https://github.com/shepherdwind/css-hot-loader/issues/21).\n\n\n### webpack 1.x\n\nConfig file example should like this\n\n```javascript\n  module: {\n    loaders: [{\n      test: /\\.less$/,\n      loaders: [\n        'css-hot-loader',\n        'extract-text-webpack-plugin',\n        'less',\n        ...\n       ],\n      include: path.join(__dirname, 'src')\n    }]\n  }\n```\n\nSee more examples code from https://github.com/shepherdwind/css-hot-loader/tree/v1.4.3/examples\n\n### options\n\n#### fileMap\n\nOption to define you css file reload rule. Since 1.1.0 .\n\nFor example `'css-hot-loader?fileMap='../css/{fileName}'` , which mean\n\n```\njs/foo.js => css/foo.css\n```\n\nDefault value is `{fileName}`.\n\nsee [#3](https://github.com/shepherdwind/css-hot-loader/issues/3).\n\n#### reloadAll\n\nForce reload all css file.\n\n#### cssModule\n\nWhen this option is opened, every time you modify the css file, the js file will\nreload too. Default closed, this option use with css module.\n\nsee [!47](https://github.com/shepherdwind/css-hot-loader/pull/47) and [!51](https://github.com/shepherdwind/css-hot-loader/pull/51)\n\n### How\n\n\nThe realization principle of this loader is very simple. There are some assumed condition:\n\n1. css required by js , so css also be a js file\n2. The name of css file, which need hot reload , is the same as js file excuted.\n\nThe secend assumption is often established. If you use extract-text-webpack-plugin , entry `foo.js` will extract css file `foo.css`. This principle will help us to locate the url of css file extracted.\n\nBecause every css file will be a js module , every css file change can affect a module change. CSS hot loader will accept this kind change, then find extracted css file by `document.currentScript`.\n\nSo when a css file changed, We just need find which css file link element, and reload css file.\n\n### License\n\n(The MIT License)\n","publish_time":1531291134308,"_cnpm_publish_time":1531291134308,"dist-tags":{"beta":"1.4.2-beta","latest":"1.4.4"}}