html-loader
Advanced tools
Comparing version 0.2.1 to 0.2.2
13
index.js
@@ -29,2 +29,3 @@ /* | ||
} | ||
var root = query.root; | ||
var links = attrParse(content, function(tag, attr) { | ||
@@ -37,3 +38,3 @@ return attributes.indexOf(tag + ":" + attr) >= 0; | ||
links.forEach(function(link) { | ||
if(/^data:|^(https?:)?\/\/|^[\{\}\[\]#*;,'§\$%&\(=?`´\^°<>]/.test(link.value)) return; | ||
if(!loaderUtils.isUrlRequest(link.value, root)) return; | ||
do { | ||
@@ -64,12 +65,4 @@ var ident = randomIdent(); | ||
if(!data[match]) return match; | ||
return '" + require(' + JSON.stringify(urlToRequire(data[match])) + ') + "'; | ||
return '" + require(' + JSON.stringify(loaderUtils.urlToRequest(data[match], root)) + ') + "'; | ||
}) + ";"; | ||
} | ||
function urlToRequire(url) { | ||
if(/^~/.test(url)) | ||
return url.substring(1); | ||
else | ||
return "./"+url; | ||
} | ||
{ | ||
"name": "html-loader", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"author": "Tobias Koppers @sokra", | ||
@@ -9,3 +9,3 @@ "description": "html loader module for webpack", | ||
"source-map": "0.1.x", | ||
"loader-utils": "0.2.x" | ||
"loader-utils": "~0.2.2" | ||
}, | ||
@@ -12,0 +12,0 @@ "devDependencies": { |
@@ -9,2 +9,6 @@ # html loader for webpack | ||
## Usage | ||
[Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html) | ||
## Examples | ||
@@ -42,8 +46,31 @@ | ||
/// minimized | ||
/// minimized by running `webpack --optimize-minimize` | ||
// => '<img src=http://cdn.example.com/49e...ba9f/a9f...92ca.jpg data-src=data:image/png;base64,...>' | ||
``` | ||
## 'Root-relative' urls | ||
For urls that start with a `/`, the default behavior is to not translate them. | ||
If a `root` query parameter is set, however, it will be prepended to the url | ||
and then translated. | ||
With the same configuration above: | ||
``` html | ||
<!-- fileB.html --> | ||
<img src="/image.jpg"> | ||
``` | ||
``` javascript | ||
require("html!./fileB.html"); | ||
// => '<img src="/image.jpg">' | ||
require("html?root=.!./fileB.html"); | ||
// => '<img src="http://cdn.example.com/49e...ba9f/a9f...92ca.jpg">' | ||
``` | ||
## License | ||
MIT (http://www.opensource.org/licenses/mit-license.php) |
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
8645
75
200
Updatedloader-utils@~0.2.2