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 publicPath configured incorrectly for production builds? #119

Closed
pascalw opened this issue Dec 31, 2015 · 7 comments
Closed

Webpack publicPath configured incorrectly for production builds? #119

pascalw opened this issue Dec 31, 2015 · 7 comments

Comments

@pascalw
Copy link
Contributor

pascalw commented Dec 31, 2015

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?

@chentsulin
Copy link
Member

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 ./.

@pascalw
Copy link
Contributor Author

pascalw commented Jan 8, 2016

I think I may have not been clear enough.

The problem is that config.output.publicPath for production builds is configured to point to /dist/ (notice the leading slash). However this doesn't work because in production builds assets are served from the filesystem, not a webserver.

@pascalw
Copy link
Contributor Author

pascalw commented Jan 8, 2016

@jhen0409 yes exactly and that's why config.output.publicPath = '/dist/' doesn't work for production builds, as production builds run in the context of a file system meaning /dist/ would refer to the root of the filesystem.

@L-A
Copy link

L-A commented 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.

@chentsulin chentsulin reopened this Jan 14, 2016
@pascalw
Copy link
Contributor Author

pascalw commented Jan 14, 2016

@chentsulin sent a PR that fixes this.

@L-A
Copy link

L-A commented Jan 14, 2016

@pascalw Cheers! I was about to do the same thing. We've already put more effort discussing it than the correction requires :)

chentsulin added a commit that referenced this issue Jan 15, 2016
…roduction

Close #119, Fix Webpack publicPath for production builds
@chentsulin
Copy link
Member

My bad. Thanks @pascalw !

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

No branches or pull requests

3 participants