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.

Webpack publicPath configured incorrectly for production builds?

See original GitHub issue

I’m new to Webpack so I could be wrong but; I’m including font-awesome in my project and noticed that in production builds the icons would not work, because it tried to load the icon files from /dist/...ttf.

Looking at the webpack.config.production.js I noticed this snippet which I think is incorrect:

config.output.publicPath = '/dist/';

Setting that to ../dist/ fixes my problem with font-awesome. Looking at the Webpack docs I think this indeed should be ../dist/ because we’re not running a server in production builds.

Do you want me to send a PR for that?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
L-Acommented, Jan 14, 2016

Just chiming in to say that this should probably count as an issue – everyone using assets will bump into this and need to change the path, even if everything is in dist.

Since packaged assets are not requested from a server, files that are compiled to dist will currently be requested from file:///dist/assetname, because it’s configured as an absolute path.

As @pascalw is saying, with ../dist/ in config.output.publicPath, it would behave as expected.

1reaction
chentsulincommented, Jan 9, 2016

This is a non-issue, and just about directory structure preference. I prefer to put all static resources into a dist directory instead of everywhere. So, personally I will copy font files into dist directory, too.

Notice that all js and css files will bundle into dist via webpack in this boilerplate, if you want to change publicPath, you should be careful and correctly handle path and directory change.

Another thing worth to mention here is that ../dist/ have no different with ./.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Public Path - webpack
The publicPath configuration option can be quite useful in a variety of scenarios. It allows you to specify the base path for all...
Read more >
Webpack — Understanding the 'publicPath' mystery - Medium
The 2 main issues which are caused by incorrect publicPath config configuration are : webpack-dev-server : live-reload feature doesn't work ...
Read more >
Webpack, new chunk is loading in with wrong path
So I have a seperate chunk set up for my app, I can see that webpack is generating 1.bundle.js in my build folder,...
Read more >
Split your Webpack configuration for development ... - HackSoft
In this article, we'll explore how to split your Webpack configuration to have different settings for local development & for production ...
Read more >
How code-splitting and dynamic Import works - WPACK.IO
Glad you asked. The documentation at webpack output.publicPath says this is one free variable __webpack_public_path__ which can be used to define the…
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