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

gatsby-starter-blog live glitch.com playground #1515

Closed
100ideas opened this issue Jul 15, 2017 · 6 comments
Closed

gatsby-starter-blog live glitch.com playground #1515

100ideas opened this issue Jul 15, 2017 · 6 comments

Comments

@100ideas
Copy link
Contributor

100ideas commented Jul 15, 2017

gatsby-starter-blog w/ live-edit demo: https://github.com/100ideas/glitch-gatsby-starter-blog


"Glitch" by Fog Creek Software:

With working example apps to remix, a code editor to modify them, instant hosting and deployment - anybody can build a web app on Glitch, for free.

Terrific, we can all stop doing dev the old fashioned way with our cumbersome "laptops" and "terminals" and "operating systems" etc etc 👴

But can it run the mighty gatsby-starter-blog?! :trollface: 💪

Impressions

  • in-browser glitch editor can be used create/edit markdown files in src/pages/<date>-<post-name>/index.md
    • but can't (easily) upload image files to src/pages/ folders
    • because images etc are supposed to be put into glitch's assets folder, which is served by cdn
    • maybe someone will make a gatsby-source-glitch-assets plugin to help
  • authoring content & uploading / hosting media is possible, but not as simple off-the-shelf
  • gatsby/glitch live-reloads changes quickly, but currently running in dev mode
  • in general, glitch seems designed to make collaborative editing & instant hosting of app painless

Conclusion

For newcomers to gatsby, glitch-gatsby-starter-blog is potentially a painless way to explore running gatsby code with minimal friction.

Future ideas

@100ideas
Copy link
Contributor Author

Glitch apps run in docker containers on AWS behind some proxy/router layer, so to get webpack hmr working in develop mode, it is necessary to configure webpack-hot-middleware/client?path= with the containers public domain name rather than the default localhost passed in via program.host.

I ended up using an ugly hack to set the webpack-hot-middleware/client?path= string in gatsby-config.js. Besides adding logic to check for the correct _config.entry.commons[] array index to use, is there a safer/better way to do this?

gatsby-starter-blog/gatsby-config.js/modifyWebpackConfig():

exports.modifyWebpackConfig = ({ config, stage }) => {
  if (stage === `develop`) {
    config._config.entry.commons[1] = `/app/node_modules/webpack-hot-middleware/client?path=https://${process.env.PROJECT_DOMAIN}.glitch.me/__webpack_hmr&reload=true`
    config._config.output.publicPath = `https://${process.env.PROJECT_DOMAIN}.glitch.me/`
    // console.dir(config, {depth: 3})
  }
  return config
}

@KyleAMathews
Copy link
Contributor

Hey! This is awesome! You want to add this to the starters docs page that was just created earlier? https://www.gatsbyjs.org/docs/gatsby-starters/

100ideas added a commit to 100ideas/glitch-gatsby-starter-blog that referenced this issue Jul 19, 2017
@100ideas
Copy link
Contributor Author

@KyleAMathews done!

Is my approach (above) to modifying webpack-hot-middleware config ok?

@100ideas
Copy link
Contributor Author

Couldn't figure out the proper way of exposing an environment variable on the server to node/gatsby, so ended up with this sad hack using npm run prestart script: https://github.com/100ideas/glitch-gatsby-starter-blog/blob/master/package.json#L11

Would be nice to see an example of how to extend process.env using webpack.DefinePlugin() (#660) without clobbering `process.env.NODE_ENV.

#1462 is a step in the right direction but I need to access a shell variable, not static config option.

@KyleAMathews
Copy link
Contributor

Is my approach (above) to modifying webpack-hot-middleware config ok?

Yup! that looks great. BTW, it might make sense to put all this Glitch-specific code into a Glitch plugin.

@thetha
Copy link

thetha commented Jul 2, 2021

I have a question. I have tested a clean gatsby starter.
It is defenetly not working on glitch.

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