Webpack publicPath configured incorrectly for production builds?
See original GitHub issueI’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:
- Created 8 years ago
- Comments:7 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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 fromfile:///dist/assetname
, because it’s configured as an absolute path.As @pascalw is saying, with
../dist/
inconfig.output.publicPath
, it would behave as expected.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./
.