html-bundler-webpack-plugin
Advanced tools
Comparing version
{ | ||
"name": "html-bundler-webpack-plugin", | ||
"version": "4.18.0", | ||
"version": "4.18.1", | ||
"description": "Generates complete single-page or multi-page website from source assets. Build-in support for Markdown, Eta, EJS, Handlebars, Nunjucks, Pug. Alternative to html-webpack-plugin.", | ||
@@ -149,3 +149,3 @@ "keywords": [ | ||
"@types/html-minifier-terser": "^7.0.2", | ||
"ansis": "3.9.0", | ||
"ansis": "3.17.0", | ||
"enhanced-resolve": ">=5.7.0", | ||
@@ -152,0 +152,0 @@ "eta": "^3.5.0", |
@@ -19,2 +19,17 @@ const fs = require('fs/promises'); | ||
/** | ||
* The output path to save generated files. | ||
* | ||
* @type {string} | ||
* */ | ||
outputPath = ''; | ||
/** | ||
* The full output public path.. | ||
* It will be used if Webpack output.publicPath ia a URL. | ||
* | ||
* @type {string} | ||
* */ | ||
outputUrl = ''; | ||
/** | ||
* The key is the source HTML file, where was found the original `faviconFile` parsed in the `faviconTag`. | ||
@@ -35,2 +50,3 @@ * The `faviconFile` is the source file of the parsed favicon file. | ||
this.options.faviconsConfig = { ...config.defaults, ...(options.faviconOptions || {}) }; | ||
this.outputPath = this.options.faviconsConfig?.path ?? ''; | ||
} | ||
@@ -41,3 +57,9 @@ | ||
const enabled = bundlerPluginOption.toBool(this.options?.enabled, true, 'auto'); | ||
const isUrlPublicPath = bundlerPluginOption.isUrlPublicPath(); | ||
if (isUrlPublicPath) { | ||
let publicPath = bundlerPluginOption.getPublicPath(); | ||
this.outputUrl = new URL(this.outputPath, publicPath).href; | ||
} | ||
if (!enabled) { | ||
@@ -96,2 +118,3 @@ return; | ||
let outputFile = path.posix.join(this.options.faviconsConfig.path, name); | ||
compilation.emitAsset(outputFile, new RawSource(contents)); | ||
@@ -109,3 +132,11 @@ }); | ||
if (page && this.faviconResponse) { | ||
content = content.replace(page.faviconTag, this.faviconResponse.html); | ||
let { outputUrl, outputPath } = this; | ||
let faviconHtml = this.faviconResponse.html; | ||
if (outputUrl) { | ||
faviconHtml = faviconHtml.replaceAll(outputPath, outputUrl); | ||
} | ||
// inject generated <link> tags | ||
content = content.replace(page.faviconTag, faviconHtml); | ||
} | ||
@@ -112,0 +143,0 @@ |
Sorry, the diff of this file is too big to display
784204
0.11%13770
0.18%+ Added
- Removed
Updated