html-webpack-plugin
Advanced tools
Comparing version 5.2.0 to 5.3.0
@@ -5,2 +5,10 @@ # Changelog | ||
## [5.3.0](https://github.com/jantimon/html-webpack-plugin/compare/v5.2.0...v5.3.0) (2021-03-07) | ||
### Features | ||
* allow to modify the interpolation options in webpack config ([d654f5b](https://github.com/jantimon/html-webpack-plugin/commit/d654f5b90022304335b372d424ff4c08d3a9d341)) | ||
* drop loader-utils dependency ([41d7a50](https://github.com/jantimon/html-webpack-plugin/commit/41d7a50516aefd1af2704e3837d5d41351c6199b)) | ||
## [5.2.0](https://github.com/jantimon/html-webpack-plugin/compare/v5.1.0...v5.2.0) (2021-02-19) | ||
@@ -7,0 +15,0 @@ |
@@ -5,12 +5,10 @@ /* This loader renders the template with underscore if no other loader was found */ | ||
const _ = require('lodash'); | ||
const loaderUtils = require('loader-utils'); | ||
module.exports = function (source) { | ||
// Get templating options | ||
const options = this.query !== '' ? loaderUtils.getOptions(this) : {}; | ||
const options = this.getOptions(); | ||
const force = options.force || false; | ||
const allLoadersButThisOne = this.loaders.filter(function (loader) { | ||
return loader.normal !== module.exports; | ||
}); | ||
const allLoadersButThisOne = this.loaders.filter((loader) => loader.normal !== module.exports); | ||
// This loader shouldn't kick in if there is any other loader (unless it's explicitly enforced) | ||
@@ -20,2 +18,10 @@ if (allLoadersButThisOne.length > 0 && !force) { | ||
} | ||
// Allow only one html-webpack-plugin loader to allow loader options in the webpack config | ||
const htmlWebpackPluginLoaders = this.loaders.filter((loader) => loader.normal === module.exports); | ||
const lastHtmlWebpackPluginLoader = htmlWebpackPluginLoaders[htmlWebpackPluginLoaders.length - 1]; | ||
if (this.loaders[this.loaderIndex] !== lastHtmlWebpackPluginLoader) { | ||
return source; | ||
} | ||
// Skip .js files (unless it's explicitly enforced) | ||
@@ -28,3 +34,3 @@ if (/\.js$/.test(this.resourcePath) && !force) { | ||
// | ||
const template = _.template(source, _.defaults(options, { interpolate: /<%=([\s\S]+?)%>/g, variable: 'data' })); | ||
const template = _.template(source, { interpolate: /<%=([\s\S]+?)%>/g, variable: 'data', ...options }); | ||
// Use __non_webpack_require__ to enforce using the native nodejs require | ||
@@ -31,0 +37,0 @@ // during template execution |
{ | ||
"name": "html-webpack-plugin", | ||
"version": "5.2.0", | ||
"version": "5.3.0", | ||
"license": "MIT", | ||
@@ -37,6 +37,6 @@ "description": "Simplifies creation of HTML files to serve your webpack bundles", | ||
"dir-compare": "1.7.2", | ||
"html-loader": "2.0.0", | ||
"html-loader": "2.1.1", | ||
"jest": "26.5.3", | ||
"mini-css-extract-plugin": "1.0.0", | ||
"pug": "2.0.3", | ||
"pug": "3.0.2", | ||
"pug-loader": "2.4.0", | ||
@@ -56,3 +56,2 @@ "raw-loader": "4.0.2", | ||
"html-minifier-terser": "^5.0.1", | ||
"loader-utils": "^2.0.0", | ||
"lodash": "^4.17.20", | ||
@@ -59,0 +58,0 @@ "pretty-error": "^2.1.1", |
@@ -97,3 +97,3 @@ import { AsyncSeriesWaterfallHook } from "tapable"; | ||
* | ||
* @default 'blocking' | ||
* @default 'defer' | ||
*/ | ||
@@ -100,0 +100,0 @@ scriptLoading?: "blocking" | "defer"; |
150993
6
2212
- Removedloader-utils@^2.0.0
- Removedbig.js@5.2.2(transitive)
- Removedemojis-list@3.0.0(transitive)
- Removedjson5@2.2.3(transitive)
- Removedloader-utils@2.0.4(transitive)