Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack 5.1.3 and PublicPath auto #95

Open
Magi-KS opened this issue Oct 17, 2020 · 3 comments · May be fixed by #108
Open

Webpack 5.1.3 and PublicPath auto #95

Magi-KS opened this issue Oct 17, 2020 · 3 comments · May be fixed by #108

Comments

@Magi-KS
Copy link

Magi-KS commented Oct 17, 2020

Webpack: 5.1.3
extract-loader: 5.1.0

there's this PR webpack/webpack#11258 that was merged and released as part of Webpack 5.1.3 which changes the default publicPath option to auto.

and getPublicPath function that refers to the variable in this line

which result in require("./assets/styles/style.css") being resolved to <link rel="stylesheet" href="autoad70c8b2da42929dc855c3fd20c749b2.css"/>\n'

notice the auto.

I personally do not have any context on how this should be properly handled for extract-loader.
If any veteran would provide a direction I can make the changes and submit a PR.

for people that needs a quick fix, just explicitly provide the option of publicPath as empty string like so

          {
            loader: "extract-loader",
            options: {
              publicPath: "",
            }
          },
@isaacl
Copy link

isaacl commented Nov 2, 2020

yeah not sure either. Possibly the following is correct, but I'm not sure if that makes extract-loader handle 'auto' correctly:

diff --git a/src/extractLoader.js b/src/extractLoader.js
index 677388d..6859ba9 100644
--- a/src/extractLoader.js
+++ b/src/extractLoader.js
@@ -216,7 +216,8 @@ function getPublicPath(options, context) {
         return context.options.output.publicPath;
     }

-    if (context._compilation && context._compilation.outputOptions && "publicPath" in context._compilation.outputOptions) {
+    if (context._compilation && context._compilation.outputOptions && "publicPath" in context._compilation.outputOptions &&
+        context._compilation.outputOptions.publicPath !== 'auto') {
         return context._compilation.outputOptions.publicPath;
     }

@IgnusG
Copy link

IgnusG commented Feb 16, 2021

@isaacl tried it with patch-package (since it's the only package that was broken for me in webpack@5) and it worked well for now

@IgnusG
Copy link

IgnusG commented Feb 16, 2021

Here's the favicons-webpack-plugin's commit that addresses a similar issue jantimon/favicons-webpack-plugin@7293186
I think the solution is fairly similar to the above one

@tlusk tlusk linked a pull request Jun 21, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants