From 7c3146d5859941b6c9b4189bf185785e886b2018 Mon Sep 17 00:00:00 2001 From: Jan Nicklas Date: Sun, 3 Jan 2021 14:12:07 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20allow=20to=20set=20publicPath=20to=20em?= =?UTF-8?q?pty=20string=20=E2=80=99=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BREAKING CHANGE: Setting publicPath to an empty string will no longer calculate a relative path from the html file to the assets anymore. To keep the old behaviour set the publicPath to ‘auto’ --- index.js | 4 ++-- spec/basic.spec.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 2f760be1..4aa82c02 100644 --- a/index.js +++ b/index.js @@ -565,8 +565,8 @@ function hookIntoCompiler (compiler, options, plugin) { */ const webpackPublicPath = compilation.getAssetPath(compilation.outputOptions.publicPath, { hash: compilationHash }); - // Webpack 5 introduced "auto" - however it can not be retrieved at compile time - const isPublicPathDefined = webpackPublicPath.trim() !== '' && webpackPublicPath !== 'auto'; + // Webpack 5 introduced "auto" as default value + const isPublicPathDefined = webpackPublicPath !== 'auto'; let publicPath = // If the html-webpack-plugin options contain a custom public path uset it diff --git a/spec/basic.spec.js b/spec/basic.spec.js index f9773403..61d392ae 100644 --- a/spec/basic.spec.js +++ b/spec/basic.spec.js @@ -843,6 +843,37 @@ describe('HtmlWebpackPlugin', () => { }, ['