Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

html-loader

Package Overview
Dependencies
Maintainers
8
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.4.4 to 0.4.5

14

index.js

@@ -17,3 +17,3 @@ /*

function getLoaderConfig(context) {
var query = loaderUtils.parseQuery(context.query);
var query = loaderUtils.getOptions(context) || {};
var configKey = query.config || 'htmlLoader';

@@ -128,4 +128,12 @@ var config = context.options && context.options.hasOwnProperty(configKey) ? context.options[configKey] : {};

}
return "module.exports = " + content.replace(/xxxHTMLLINKxxx[0-9\.]+xxx/g, function(match) {
var exportsString = "module.exports = ";
if (config.exportAsDefault) {
exportsString = "exports.default = ";
} else if (config.exportAsEs6Default) {
exportsString = "export default ";
}
return exportsString + content.replace(/xxxHTMLLINKxxx[0-9\.]+xxx/g, function(match) {
if(!data[match]) return match;

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

{
"name": "html-loader",
"version": "0.4.4",
"version": "0.4.5",
"author": "Tobias Koppers @sokra",

@@ -10,3 +10,3 @@ "description": "html loader module for webpack",

"html-minifier": "^3.0.1",
"loader-utils": "^0.2.15",
"loader-utils": "^1.0.2",
"object-assign": "^4.1.0"

@@ -13,0 +13,0 @@ },

@@ -39,5 +39,5 @@ [![npm][npm]][npm-url]

module: {
loaders: [
{ test: /\.jpg$/, loader: "file-loader" },
{ test: /\.png$/, loader: "url-loader?mimetype=image/png" }
rules: [
{ test: /\.jpg$/, use: [ "file-loader" ] },
{ test: /\.png$/, use: [ "url-loader?mimetype=image/png" ] }
]

@@ -57,3 +57,3 @@ },

```js
require("html!./file.html");
require("html-loader!./file.html");

@@ -65,3 +65,3 @@ // => '<img src="http://cdn.example.com/49eba9f/a992ca.png"

```js
require("html?attrs=img:data-src!./file.html");
require("html-loader?attrs=img:data-src!./file.html");

@@ -72,4 +72,4 @@ // => '<img src="image.png" data-src="data:image/png;base64,..." >'

```js
require("html?attrs=img:src img:data-src!./file.html");
require("html?attrs[]=img:src&attrs[]=img:data-src!./file.html");
require("html-loader?attrs=img:src img:data-src!./file.html");
require("html-loader?attrs[]=img:src&attrs[]=img:data-src!./file.html");

@@ -81,3 +81,3 @@ // => '<img src="http://cdn.example.com/49eba9f/a992ca.png"

```js
require("html?-attrs!./file.html");
require("html-loader?-attrs!./file.html");

@@ -94,2 +94,18 @@ // => '<img src="image.jpg" data-src="image2x.png" >'

or specify the `minimize` property in the rule's options in your `webpack.conf.js`
```js
module: {
rules: [{
test: /\.html$/,
use: [ {
loader: 'html-loader',
options: {
minimize: true
}
}],
}]
}
```
### 'Root-relative' URLs

@@ -109,3 +125,3 @@

```js
require("html!./file.html");
require("html-loader!./file.html");

@@ -116,3 +132,3 @@ // => '<img src="/image.jpg">'

```js
require("html?root=.!./file.html");
require("html-loader?root=.!./file.html");

@@ -127,3 +143,3 @@ // => '<img src="http://cdn.example.com/49eba9f/a992ca.jpg">'

```js
require("html?interpolate!./file.html");
require("html-loader?interpolate!./file.html");
```

@@ -136,6 +152,6 @@

```
And if you only want to use `require` in template and any other `${}` are not to be translate you can set `interpolate` flag to `require`, like so:
And if you only want to use `require` in template and any other `${}` are not to be translated, you can set `interpolate` flag to `require`, like so:
```js
require("html?interpolate=require!./file.ftl");
require("html-loader?interpolate=require!./file.ftl");
```

@@ -154,2 +170,10 @@

### Export formats
There are different export formats available:
+ ```module.exports``` (default, cjs format). "Hello world" becomes ```module.exports = "Hello world";```
+ ```exports.default``` (when ```exportAsDefault``` param is set, es6to5 format). "Hello world" becomes ```exports.default = "Hello world";```
+ ```export default``` (when ```exportAsEs6Default``` param is set, es6 format). "Hello world" becomes ```export default "Hello world";```
### Advanced options

@@ -165,9 +189,9 @@

module: {
loaders: [
rules: [
{
test: /\.html$/,
loader: "html"
use: [ "html-loader" ]
}
]
}
},
htmlLoader: {

@@ -181,3 +205,3 @@ ignoreCustomFragments: [/\{\{.*?}}/],

If you need to define two different loader configs, you can also change the config's property name via `html?config=otherHtmlLoaderConfig`:
If you need to define two different loader configs, you can also change the config's property name via `html-loader?config=otherHtmlLoaderConfig`:

@@ -188,9 +212,9 @@ ```js

module: {
loaders: [
rules: [
{
test: /\.html$/,
loader: "html?config=otherHtmlLoaderConfig"
use: [ "html-loader?config=otherHtmlLoaderConfig" ]
}
]
}
},
otherHtmlLoaderConfig: {

@@ -202,2 +226,24 @@ ...

### Export into HTML files
A very common scenario is exporting the HTML into their own _.html_ file, to
serve them directly instead of injecting with javascript. This can be achieved
with a combination of 3 loaders:
- [file-loader](https://github.com/webpack/file-loader)
- [extract-loader](https://github.com/peerigon/extract-loader)
- html-loader
The html-loader will parse the URLs, require the images and everything you
expect. The extract loader will parse the javascript back into a proper html
file, ensuring images are required and point to proper path, and the file loader
will write the _.html_ file for you. Example:
```js
{
test: /\.html$/,
use: [ 'file-loader?name=[path][name].[ext]!extract-loader!html-loader' ]
}
```
<h2 align="center">Maintainers</h2>

@@ -209,9 +255,11 @@

<td align="center">
<img width="150 height="150"
<img width="150" height="150"
src="https://avatars.githubusercontent.com/u/18315?v=3">
<a href="https://github.com/hemanth">Hermanth</a>
</br>
<a href="https://github.com/hemanth">Hemanth</a>
</td>
<td align="center">
<img width="150 height="150"
<img width="150" height="150"
src="https://avatars.githubusercontent.com/u/8420490?v=3">
</br>
<a href="https://github.com/d3viant0ne">Joshua Wiens</a>

@@ -221,2 +269,3 @@ </td>

<img width="150" height="150" src="https://avatars.githubusercontent.com/u/5419992?v=3">
</br>
<a href="https://github.com/michael-ciniawsky">Michael Ciniawsky</a>

@@ -227,9 +276,11 @@ </td>

src="https://avatars.githubusercontent.com/u/6542274?v=3">
</br>
<a href="https://github.com/imvetri">Imvetri</a>
</td>
</tr>
<tr>
<tr>
<td align="center">
<img width="150" height="150"
src="https://avatars.githubusercontent.com/u/1520965?v=3">
</br>
<a href="https://github.com/andreicek">Andrei Crnković</a>

@@ -240,2 +291,3 @@ </td>

src="https://avatars.githubusercontent.com/u/3367801?v=3">
</br>
<a href="https://github.com/abouthiroppy">Yuta Hiroto</a>

@@ -245,2 +297,3 @@ </td>

<img width="150" height="150" src="https://avatars.githubusercontent.com/u/80044?v=3">
</br>
<a href="https://github.com/petrunov">Vesselin Petrunov</a>

@@ -251,34 +304,10 @@ </td>

src="https://avatars.githubusercontent.com/u/973543?v=3">
</br>
<a href="https://github.com/gajus">Gajus Kuizinas</a>
</td>
<tr>
<tbody>
</tr>
</tbody>
</table>
<h2 align="center">LICENSE</h2>
> MIT
> http://www.opensource.org/licenses/mit-license.php
> Copyright (c) 2016 Tobias Koppers @sokra
> Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
> The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
[npm]: https://img.shields.io/npm/v/html-loader.svg

@@ -285,0 +314,0 @@ [npm-url]: https://npmjs.com/package/html-loader

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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