question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Usage of webpack public path inconsistent

See original GitHub issue

Related to https://github.com/arthurbergmz/webpack-pwa-manifest/issues/5

It seems I might have jumped too early. There is an issue with the option useWebpackPublicPath and its handling in the HtmlWebpackPlugin. First, I’m of the opinion that this option is irrelevant (the manifest.json should always be generated in the output path). Nevertheless, I’d like to go through the inconsistency of its usage right now. So, with following webpack options:

  • path: dist/
  • publicPath: /assets/

as ./dist and with the (default) value of false, it will:

  • generate the manifest.json in the output path: ./dist/manifest.[hash].json
  • inject the link tag <link rel="manifest" href="manifest.[hash].json" />

so, the file is in the proper place, but the url is wrong (it should contain the publicPath from webpack). when I switch it to true (use webpack public path):

  • generates the manifest.json in this path: ./dist/assets/manifest.[hash].json
  • inject the link tag <link rel="manifest" href="/assets/manifest.[hash].json" />

so now the URL is right, but the file isn’t in the proper place, therefore the server will return 404.

My feeling is that, somewhere in the codebase, both options are being misused. Nevertheless, I’d remove the useWebpackPublicPath option altogether and just use the right webpack variables.

What do you think?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
HoneyryderChuckcommented, Jul 12, 2017

Thx also for the quick fix, mate! 😃

1reaction
HoneyryderChuckcommented, Jul 12, 2017

@arthurbergmz file is in the right place, and the url is the right one. I approve this fix 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack — Understanding the 'publicPath' mystery - Medium
Further, we can use webpack's publicPath to config wepack-dev-server to generate the bundled output files at some virtual location and not ...
Read more >
Webpack - Inconsistent contenthash between DevServer and ...
Turns out the reason for the mismatch was some absolute paths generated by some of the plugins/loaders. Since webpack-dev-server serves the ...
Read more >
Output - webpack
By default [id].js is used or a value inferred from output.filename ( [name] ... [resource], The path used to resolve the file and...
Read more >
How I solved and debugged my Webpack issue through trial ...
src/index.js' }, output: { path: path.resolve(__dirname, 'dist'), ... they recommend to use webpack-serve instead of webpack-dev-server.
Read more >
Shared Options - Vite
Base public path when served in development or production. ... build implement define differently, we should avoid some use cases to avoid inconsistency....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found