css-hot-loader
Advanced tools
Comparing version 1.3.1 to 1.3.2
@@ -0,1 +1,5 @@ | ||
### 1.3.2 / 2017-10-07 | ||
- memory leak fix, only reload css files [#22](https://github.com/shepherdwind/css-hot-loader/pull/22) by @nickaversano | ||
### 1.3.1 / 2017-09-04 | ||
@@ -2,0 +6,0 @@ |
@@ -30,9 +30,15 @@ var normalizeUrl = require('normalize-url'); | ||
function updateCss(el, url) { | ||
var newEl = el.cloneNode(); | ||
if (!url) { | ||
url = el.href.split('?')[0]; | ||
} | ||
if (!url || !(url.indexOf('.css') > -1)) return; | ||
var newEl = el.cloneNode(); | ||
newEl.addEventListener('load', function () { | ||
el.remove(); | ||
}); | ||
newEl.addEventListener('error', function () { | ||
el.remove(); | ||
}); | ||
newEl.href = url + '?' + Date.now(); | ||
@@ -45,3 +51,3 @@ el.parentNode.insertBefore(newEl, el.nextSibling); | ||
var loaded = false; | ||
for (var i = 0, el = null; el = elements[i]; i++) { | ||
[].slice.call(elements).forEach(function(el) { | ||
var url = getReloadUrl(el.href, src); | ||
@@ -52,3 +58,3 @@ if (url) { | ||
} | ||
} | ||
}); | ||
return loaded; | ||
@@ -70,5 +76,5 @@ } | ||
var elements = document.querySelectorAll('link'); | ||
for (var i = 0, el = null; el = elements[i]; i++) { | ||
[].slice.call(elements).forEach(function(el) { | ||
updateCss(el); | ||
} | ||
}); | ||
} | ||
@@ -75,0 +81,0 @@ |
{ | ||
"name": "css-hot-loader", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "css hot reload work with extract-text-webpack-plugin", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -40,2 +40,28 @@ ### CSS Hot Loader | ||
```javascript | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/, | ||
use: ['css-hot-loader'].concat(ExtractTextPlugin.extract({ | ||
fallback: 'style-loader', | ||
use: 'css-loader' | ||
})), | ||
}, | ||
] | ||
} | ||
``` | ||
`css-hot-loader` should be the first loader before `extract-text-webpack-plugin`. | ||
### Attention | ||
This plugin require the output css file name static. If output file name depend | ||
on css content, for example `'bundle.[name].[contenthash].css'`, HMR reload will | ||
fail, more detail refer to [#21](https://github.com/shepherdwind/css-hot-loader/issues/21). | ||
### webpack 1.x | ||
Config file example should like this | ||
```javascript | ||
module: { | ||
@@ -55,22 +81,2 @@ loaders: [{ | ||
`css-hot-loader` should be the first loader before `extract-text-webpack-plugin`. | ||
### webpack 2.x | ||
Config file example should like this | ||
```javascript | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/, | ||
use: ['css-hot-loader'].concat(ExtractTextPlugin.extract({ | ||
fallback: 'style-loader', | ||
use: 'css-loader' | ||
})), | ||
}, | ||
] | ||
} | ||
``` | ||
### options | ||
@@ -77,0 +83,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9825
105
113