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

src paths for files are '/' and for a static site should be './' in build #95

Closed
selfup opened this issue Jul 22, 2016 · 9 comments
Closed

Comments

@selfup
Copy link

selfup commented Jul 22, 2016

Currently the src paths are not friendly for a static site. They only work for using a server.

Is there any plan to make this work with a simple: open index.html?

Or is this project only intended for people running this on a server?

@gaearon
Copy link
Contributor

gaearon commented Jul 22, 2016

I think the problem with ./ is it doesn’t work for single page apps with routing.
For example when you load localhost:3000/products, you don’t want to load products/main.js.

Since most React apps are single page apps (and most SPAs use HTML5 history over hashes these days), I think we we’ll have to stick with requiring a server for the bundle. But maybe I’m wrong.

@selfup
Copy link
Author

selfup commented Jul 22, 2016

@vjeux Thanks for the response!

Yea so currently if I am in a gh-pages branch and run:

fs.readdirSync("./").forEach(toBeErased => {
  if (toBeErased === "react-gh.js" || toBeErased === "build" || toBeErased === ".git" || toBeErased === "node_modules" | toBeErased === "src") {

  } else {
    fs.unlinkSync(toBeErased)
  }
})

fs.readdirSync('build').forEach(file => {
  fileContents = fs.readFileSync(`build/${file}`)
  fs.writeFileSync(file, fileContents)
})

Everything looks fine, but the html is clueless haha.

I got it to work perfectly after manually changing the paths :)

@selfup
Copy link
Author

selfup commented Jul 22, 2016

@gaearon Never thought about the routing part. Good catch

@vjeux
Copy link
Contributor

vjeux commented Jul 22, 2016

Sorry, deleted my response. #21 is also talking about the same issue

@selfup
Copy link
Author

selfup commented Jul 22, 2016

@vjeux Is that just for the package.json or does that include the src for the script and link tags?

@selfup
Copy link
Author

selfup commented Jul 22, 2016

Ok it seems this is being covered in multiple Issues. I couldn't tell from the titles!

Feel free to keep open or close

@gaearon
Copy link
Contributor

gaearon commented Jul 22, 2016

Let’s continue in #21.

@gaearon gaearon closed this as completed Jul 22, 2016
@gaearon
Copy link
Contributor

gaearon commented Jul 27, 2016

GH Pages should work with 0.2.0 alpha, here's how to test it: #190

@selfup
Copy link
Author

selfup commented Jul 28, 2016

Fantastic! Thanks for the update

@lock lock bot locked and limited conversation to collaborators Jan 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants