Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

[Issue] Pushstate webpack dev server public path #175

Closed
rj254 opened this issue Apr 11, 2017 · 14 comments
Closed

[Issue] Pushstate webpack dev server public path #175

rj254 opened this issue Apr 11, 2017 · 14 comments

Comments

@rj254
Copy link

rj254 commented Apr 11, 2017

remix-run/react-router#676 (comment)

There should probably be an option to set publicPath on the devServer so that react-router and other libraries that rely on it can work out of the box.

@eliperelman
Copy link
Member

@rj254 it seems like the solution is to just set the devServer.publicPath to config.output.publicPath. Does that sound right?

@rj254
Copy link
Author

rj254 commented Apr 11, 2017

I believe so, locally I had to set both the output path to '/' and the devServer.publicPath to '/' in order to get this to work.

More (relevant) information can be found here: react-boilerplate/react-boilerplate#113

@eliperelman
Copy link
Member

Cool, I'll upgrade webpack-chain, then the web middleware accordingly.

@eliperelman
Copy link
Member

eliperelman commented Apr 12, 2017

Setting the devServer.publicPath to the same value ends up with the public path being ./, which broke things. Any idea why that is?

@eliperelman
Copy link
Member

Make sure publicPath always starts and ends with a forward slash.

@rj254
Copy link
Author

rj254 commented Apr 12, 2017

I believe devServer.publicPath has a set of rules including that the path should start and end with / . It turns out the default is also just "/". What really should happen is that the output public path should be specified as "/" not "./" when using the HTML webpack plugin.

@eliperelman
Copy link
Member

@rj254 would you mind testing out #179 to see if it fulfills all the use cases you describe?

@rj254
Copy link
Author

rj254 commented Apr 12, 2017

Sure

@rj254
Copy link
Author

rj254 commented Apr 14, 2017

Unfortunately, the changes in #179 did not fix the issue. There is no need to set publicPath to '/' as it is defaulted to '/'. The webpack docs additionally recommend the following:
It is recommended that devServer.publicPath is the same as output.publicPath.
output.publicPath should not be configured to ./ and should instead be configured to /

@constgen
Copy link
Contributor

I think in dev run publicPath should always be overridden to "/" and in prod run to stay the same as consumer defined.

@eliperelman
Copy link
Member

So, we can't set devServer.publicPath to ./, which is what output.publicPath is set to. Is there anything that should be done here, or are these changes that should be made in userland if necessary?

@constgen
Copy link
Contributor

Please don't set output.publicPath to / during the build. It breaks possibility to doubleclick the index.html to run the application from the local file system. Keep it ./ (or what consumer set) when neutrino build and / when neutrino start and probably neutrino test

@eliperelman
Copy link
Member

@constgen yep, this is about what the best value to set devServer.publicPath is.

@constgen
Copy link
Contributor

I believe this is done and can be closed. We explicitly set publicPath: '/' when start a Dev Server and keep untouched publicPapth when build. So the consumer can configure it by itself.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants