css-hot-loader
Advanced tools
Comparing version 1.2.0 to 1.3.0-beta
var normalizeUrl = require('normalize-url'); | ||
var srcByModuleId = Object.create(null); | ||
var getCurrentScriptUrl = function() { | ||
var src; | ||
if (document) { | ||
var getCurrentScriptUrl = function(moduleId) { | ||
var src = srcByModuleId[moduleId]; | ||
if (!src && document) { | ||
if (document.currentScript) { | ||
@@ -12,2 +13,3 @@ src = document.currentScript.src; | ||
} | ||
srcByModuleId[moduleId] = src; | ||
} | ||
@@ -23,3 +25,3 @@ | ||
var reg = new RegExp(filename + '\\.js$', 'g') | ||
return normalizeUrl(src.replace(reg, mapRule.replace(/{fileName}/g, filename) + '.css')); | ||
return normalizeUrl(src.replace(reg, mapRule.replace(/{fileName}/g, filename) + '.css'), { stripWWW: false }); | ||
}); | ||
@@ -29,4 +31,2 @@ }; | ||
var getScriptSrc = getCurrentScriptUrl(); | ||
function updateCss(el, url) { | ||
@@ -58,3 +58,3 @@ var newEl = el.cloneNode(); | ||
function getReloadUrl(href, src) { | ||
href = normalizeUrl(href); | ||
href = normalizeUrl(href, { stripWWW: false }); | ||
var ret; | ||
@@ -76,3 +76,4 @@ src.some(function(url) { | ||
module.exports = function(options) { | ||
module.exports = function(moduleId, options) { | ||
var getScriptSrc = getCurrentScriptUrl(moduleId); | ||
return function() { | ||
@@ -79,0 +80,0 @@ if (typeof document === 'undefined') { |
@@ -16,3 +16,3 @@ const loaderUtils = require('loader-utils'); | ||
// ${Date.now()} | ||
const cssReload = require(${loaderUtils.stringifyRequest(this, require.resolve('./hotModuleReplacement'))})(${JSON.stringify(options)}); | ||
const cssReload = require(${loaderUtils.stringifyRequest(this, require.resolve('./hotModuleReplacement'))})(module.id, ${JSON.stringify(options)}); | ||
module.hot.dispose(cssReload); | ||
@@ -19,0 +19,0 @@ module.hot.accept(undefined, cssReload); |
{ | ||
"name": "css-hot-loader", | ||
"version": "1.2.0", | ||
"version": "1.3.0-beta", | ||
"description": "css hot reload work with extract-text-webpack-plugin", | ||
@@ -10,2 +10,7 @@ "main": "index.js", | ||
}, | ||
"files": [ | ||
"loader.js", | ||
"hotModuleReplacement.js", | ||
"index.js" | ||
], | ||
"homepage": "http://git.shepherdwind.com/css-hot-loader/", | ||
@@ -12,0 +17,0 @@ "repository": { |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
101
8267
7
3