React-redux-starter-kit: Set BASENAME not working

Created on 23 Jun 2016  路  4Comments  路  Source: davezuko/react-redux-starter-kit

I checked the solution of #852 which says we can deploy app to subfolder by setting the BASENAME. But that doesn't work for me, the passing BASENAME didn't change the src url script tag, they always point to /.

I also tried to change the compiler_public_path on environement.js. This time the first 2 chunks js and css were loaded, but not the rest. There is no console error and the page stays blank.

I would like to know the proper way to deploy the dist files to a subfolder like /sub. Any idea?

Most helpful comment

@golgistudio Thank you for your push. I found that we could do that a bit simpler:

  1. Change compiler_public_path to subfolder path, for example '/sub/'
  2. Pass same BASENAME on npm compile, just like this: BASENAME='/sub/' npm run deploy:prod

And you shall get script route complied correctly that will work on subfolder.

@davezuko Since many people hosting app on sub folder, do you think it worths a few words on the doc?

All 4 comments

You either need to monkey patch your asset tags or use something like https://github.com/bripkens/connect-history-api-fallback on your app server to redirect all non-route requests to your root index.html file. If you are using Nginx, you can do the same there as well. Your only other option is to perform universal rendering, which is outside of the scope of this project.

Ignore ^^, I misread your issue.

Thanks @davezuko for fast response :) I might figure it out. I will do more test to confirm my solution and will let you know asap.

Was having a similar problem - I need to publish to gh-pages, and also host on a wordpress site. Needed to make two changes

1) Change compiler_public_path in config/environments.js for the production configuration to '' instead of '/' as @nie-xin did.
2) Change src/main.js to use createHashHistory instead of createBrowserHistory.

I've published the prod build to gh-pages here

Code change is here
https://github.com/davezuko/react-redux-starter-kit/compare/master...golgistudio:master

createBrowserHistory vs createHashHistory description is here. createBrowserHistory is preferable in most cases - react-router docs...
https://github.com/reactjs/react-router/blob/master/docs/guides/Histories.md

@golgistudio Thank you for your push. I found that we could do that a bit simpler:

  1. Change compiler_public_path to subfolder path, for example '/sub/'
  2. Pass same BASENAME on npm compile, just like this: BASENAME='/sub/' npm run deploy:prod

And you shall get script route complied correctly that will work on subfolder.

@davezuko Since many people hosting app on sub folder, do you think it worths a few words on the doc?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

renanvalentin picture renanvalentin  路  5Comments

nickgnd picture nickgnd  路  4Comments

kolpav picture kolpav  路  4Comments

marcelloromanelli picture marcelloromanelli  路  5Comments

rpribadi-ds picture rpribadi-ds  路  5Comments