Socket
Socket
Sign inDemoInstall

html-loader

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-loader - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

46

index.js

@@ -10,2 +10,4 @@ /*

var url = require("url");
var assign = require("object-assign");
var compile = require("es6-templates").compile;

@@ -40,11 +42,10 @@ function randomIdent() {

if(!loaderUtils.isUrlRequest(link.value, root)) return;
var uri = url.parse(link.value);
if (uri.hash !== null && uri.hash !== undefined) {
uri.hash = null;
link.value = uri.format();
link.length = link.value.length;
uri.hash = null;
link.value = uri.format();
link.length = link.value.length;
}
do {

@@ -62,14 +63,29 @@ var ident = randomIdent();

if(typeof query.minimize === "boolean" ? query.minimize : this.minimize) {
content = htmlMinifier.minify(content, {
removeComments: query.removeComments !== false,
collapseWhitespace: query.collapseWhitespace !== false,
collapseBooleanAttributes: query.collapseBooleanAttributes !== false,
removeAttributeQuotes: query.removeAttributeQuotes !== false,
removeRedundantAttributes: query.removeRedundantAttributes !== false,
useShortDoctype: query.useShortDoctype !== false,
removeEmptyAttributes: query.removeEmptyAttributes !== false,
removeOptionalTags: query.removeOptionalTags !== false
var minimizeOptions = assign({}, query);
[
"removeComments",
"collapseWhitespace",
"collapseBooleanAttributes",
"removeAttributeQuotes",
"removeRedundantAttributes",
"useShortDoctype",
"removeEmptyAttributes",
"removeOptionalTags"
].forEach(function(name) {
if (typeof minimizeOptions[name] === "undefined") {
minimizeOptions[name] = true;
}
});
content = htmlMinifier.minify(content, minimizeOptions);
}
return "module.exports = " + JSON.stringify(content).replace(/xxxHTMLLINKxxx[0-9\.]+xxx/g, function(match) {
if (query.interpolate) {
content = compile('`' + content + '`').code;
} else {
content = JSON.stringify(content);
}
return "module.exports = " + content.replace(/xxxHTMLLINKxxx[0-9\.]+xxx/g, function(match) {
if(!data[match]) return match;

@@ -76,0 +92,0 @@ return '" + require(' + JSON.stringify(loaderUtils.urlToRequest(data[match], root)) + ') + "';

@@ -30,5 +30,5 @@ /*

">": "outside", // end of attributes
"(([a-zA-Z\\-]+)\\s*=\\s*\")([^\"]*)\"": processMatch,
"(([a-zA-Z\\-]+)\\s*=\\s*\')([^\']*)\'": processMatch,
"(([a-zA-Z\\-]+)\\s*=\\s*)([^\\s>]+)": processMatch
"(([a-zA-Z\\-:]+)\\s*=\\s*\")([^\"]*)\"": processMatch,
"(([a-zA-Z\\-:]+)\\s*=\\s*\')([^\']*)\'": processMatch,
"(([a-zA-Z\\-:]+)\\s*=\\s*)([^\\s>]+)": processMatch
}

@@ -35,0 +35,0 @@ });

{
"name": "html-loader",
"version": "0.3.0",
"version": "0.4.0",
"author": "Tobias Koppers @sokra",
"description": "html loader module for webpack",
"dependencies": {
"html-minifier": "^0.7.2",
"source-map": "0.1.x",
"es6-templates": "^0.2.2",
"fastparse": "^1.0.0",
"loader-utils": "~0.2.2"
"html-minifier": "^1.0.0",
"loader-utils": "~0.2.2",
"object-assign": "^4.0.1",
"source-map": "^0.5.3"
},
"devDependencies": {
"mocha": "1.17.x",
"should": "3.1.x"
"mocha": "^2.3.4",
"should": "^7.1.1"
},

@@ -16,0 +18,0 @@ "scripts": {

@@ -9,2 +9,4 @@ # html loader for webpack

To completely disable tag-attribute processing (for instance, if you're handling image loading on the client side) you can pass in `attrs=false`.
## Usage

@@ -46,2 +48,5 @@

require("html?-attrs!./file.html");
// => '<img src="image.jpg" data-src="image2x.png" >'
/// minimized by running `webpack --optimize-minimize`

@@ -74,4 +79,17 @@ // => '<img src=http://cdn.example.com/49e...ba9f/a9f...92ca.jpg data-src=data:image/png;base64,...>'

## Interpolation
You can use `interpolate` flag to enable interpolation syntax for ES6 template strings, like so:
```
require("html?interpolate!./file.html");
```
```
<img src="${require(`./images/gallery.png`)}" />
<div>${require('./partials/gallery.html')}</div>
```
## License
MIT (http://www.opensource.org/licenses/mit-license.php)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc