Skip to content
This repository was archived by the owner on Nov 7, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions .jsbeautifyrc

This file was deleted.

6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
sudo: false
language: node_js
os:
- linux

node_js:
- node
- "6"
- "4"

script: npm run travis
script: npm run cover -- --report lcovonly

after_success:
- cat ./coverage/coverage.json | node_modules/codecov.io/bin/codecov.io.js
Expand Down
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

<a name="0.5.5"></a>
## [0.5.5](https://github.com/webpack-contrib/html-loader/compare/v0.5.4...v0.5.5) (2018-01-17)


### Bug Fixes

* **index:** don't prepend `./` to the URL on `interpolate=require` (`options.interpolate`) ([#165](https://github.com/webpack-contrib/html-loader/issues/165)) ([9515410](https://github.com/webpack-contrib/html-loader/commit/9515410))



<a name="0.5.4"></a>
## [0.5.4](https://github.com/webpack-contrib/html-loader/compare/v0.5.1...v0.5.4) (2018-01-05)


### Bug Fixes

* ignore attribute if `mailto:` is present ([#145](https://github.com/webpack-contrib/html-loader/issues/145)) ([4b13d4c](https://github.com/webpack-contrib/html-loader/commit/4b13d4c))
* **index:** escape double quotes correctly (`options.interpolate`) ([#154](https://github.com/webpack-contrib/html-loader/issues/154)) ([1ef5de4](https://github.com/webpack-contrib/html-loader/commit/1ef5de4))


<a name="0.5.1"></a>
## [0.5.1](https://github.com/webpack/html-loader/compare/v0.5.0...v0.5.1) (2017-08-08)

Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ module: {
}
```

See [html-minifier](https://github.com/kangax/html-minifier#options-quick-reference)'s documentation for more information on the available options.

The enabled rules for minimizing by default are the following ones:
- removeComments
- removeCommentsFromCDATA
Expand All @@ -138,7 +140,7 @@ The enabled rules for minimizing by default are the following ones:
- minifyCSS
- removeScriptTypeAttributes
- removeStyleTypeAttributes

The rules can be disabled using the following options in your `webpack.conf.js`

```js
Expand Down Expand Up @@ -282,7 +284,7 @@ will write the _.html_ file for you. Example:
```js
{
test: /\.html$/,
use: [ 'file-loader?name=[path][name].[ext]!extract-loader!html-loader' ]
use: ['file-loader?name=[name].[ext]', 'extract-loader', 'html-loader'],
}
```

Expand Down
16 changes: 14 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module.exports = function(content) {
content = [content];
links.forEach(function(link) {
if(!loaderUtils.isUrlRequest(link.value, root)) return;

if (link.value.indexOf('mailto:') > -1 ) return;

var uri = url.parse(link.value);
Expand Down Expand Up @@ -129,6 +129,9 @@ module.exports = function(content) {
}

if(config.interpolate && config.interpolate !== 'require') {
// Double escape quotes so that they are not unescaped completely in the template string
content = content.replace(/\\"/g, "\\\\\"");
content = content.replace(/\\'/g, "\\\\\'");
content = compile('`' + content + '`').code;
} else {
content = JSON.stringify(content);
Expand All @@ -144,7 +147,16 @@ module.exports = function(content) {

return exportsString + content.replace(/xxxHTMLLINKxxx[0-9\.]+xxx/g, function(match) {
if(!data[match]) return match;
return '" + require(' + JSON.stringify(loaderUtils.urlToRequest(data[match], root)) + ') + "';

var urlToRequest;

if (config.interpolate === 'require') {
urlToRequest = data[match];
} else {
urlToRequest = loaderUtils.urlToRequest(data[match], root);
}

return '" + require(' + JSON.stringify(urlToRequest) + ') + "';
}) + ";";

}
Loading