From 9b4b57f517f4d44667765bb1c9ceb6a2b8949a72 Mon Sep 17 00:00:00 2001 From: Gerhard Seidel Date: Tue, 6 Apr 2021 21:19:51 +0800 Subject: [PATCH 1/3] Generate html file if html option is true --- index.js | 14 ++++++++++++++ package.json | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 0eb63ce..c0df325 100644 --- a/index.js +++ b/index.js @@ -241,6 +241,20 @@ module.exports = function (content) { emitCodepoints.emitFiles(this, emitCodepointsOptions, generatorOptions, options); } + if (generatorOptions.html) { + var htmlDest = generatorOptions.htmlDest ? generatorOptions.htmlDest : generatorOptions.fontName + '.html' + htmlDest = generatorOptions.dest.concat(htmlDest); + var htmlContent = res.generateHtml(urls) + var htmlFilename = loaderUtils.interpolateName(this, + htmlDest, + { + context: this.rootContext || this.options.context || this.context, + content: htmlContent + } + ); + this.emitFile(htmlFilename, htmlContent); + } + cb(null, res.generateCss(urls)); }); }; diff --git a/package.json b/package.json index 3687a16..bf84be2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "webfonts-loader", "version": "7.2.0", - "description": "A WebPack loader to automaticaly generate font files and CSS to make your own icon font", + "description": "A WebPack loader to automatically generate font files and CSS to make your own icon font", "repository": "jeerbl/webfonts-loader", "main": "index.js", "scripts": { @@ -25,7 +25,7 @@ }, "license": "MIT", "dependencies": { - "@vusion/webfonts-generator": "^0.7.0", + "@vusion/webfonts-generator": "^0.7.1", "glob": "^7.1.6", "loader-utils": "^2.0.0" }, From b2c3f6f39428fd85f95000e22e395c8f746bbdfb Mon Sep 17 00:00:00 2001 From: Gerhard Seidel Date: Wed, 7 Apr 2021 13:39:50 +0800 Subject: [PATCH 2/3] Use relative urls for html --- index.js | 15 ++++++++++----- package.json | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index c0df325..da3f1e0 100644 --- a/index.js +++ b/index.js @@ -244,15 +244,20 @@ module.exports = function (content) { if (generatorOptions.html) { var htmlDest = generatorOptions.htmlDest ? generatorOptions.htmlDest : generatorOptions.fontName + '.html' htmlDest = generatorOptions.dest.concat(htmlDest); - var htmlContent = res.generateHtml(urls) - var htmlFilename = loaderUtils.interpolateName(this, + htmlDest = loaderUtils.interpolateName(this, htmlDest, { - context: this.rootContext || this.options.context || this.context, - content: htmlContent + context: this.rootContext || this.options.context || this.context } ); - this.emitFile(htmlFilename, htmlContent); + + var relativeUrls = {}; + for (var key in urls) { + relativeUrls[key] = path.relative(url.resolve(publicPath, path.dirname(htmlDest.replace(/\\/g, '/'))), urls[key]); + } + + var htmlContent = res.generateHtml(relativeUrls) + this.emitFile(htmlDest, htmlContent); } cb(null, res.generateCss(urls)); diff --git a/package.json b/package.json index bf84be2..4ebcdab 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ }, "license": "MIT", "dependencies": { - "@vusion/webfonts-generator": "^0.7.1", + "@vusion/webfonts-generator": "^0.7.2", "glob": "^7.1.6", "loader-utils": "^2.0.0" }, From fd299a50cab1798beb573604b3970606201087a8 Mon Sep 17 00:00:00 2001 From: Gerhard Seidel Date: Wed, 7 Apr 2021 17:47:42 +0800 Subject: [PATCH 3/3] Fix semicolon checks --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index da3f1e0..e8dca12 100644 --- a/index.js +++ b/index.js @@ -242,7 +242,7 @@ module.exports = function (content) { } if (generatorOptions.html) { - var htmlDest = generatorOptions.htmlDest ? generatorOptions.htmlDest : generatorOptions.fontName + '.html' + var htmlDest = generatorOptions.htmlDest ? generatorOptions.htmlDest : generatorOptions.fontName + '.html'; htmlDest = generatorOptions.dest.concat(htmlDest); htmlDest = loaderUtils.interpolateName(this, htmlDest, @@ -256,7 +256,7 @@ module.exports = function (content) { relativeUrls[key] = path.relative(url.resolve(publicPath, path.dirname(htmlDest.replace(/\\/g, '/'))), urls[key]); } - var htmlContent = res.generateHtml(relativeUrls) + var htmlContent = res.generateHtml(relativeUrls); this.emitFile(htmlDest, htmlContent); }