queerviolet / bones

MIT License
36 stars 119 forks source link

Use webpack-dev-middleware or similar? #22

Closed glebec closed 7 years ago

glebec commented 7 years ago

This can improve the build process by making refreshes wait for builds to recompile before serving the updated bundle. Since the bundle is compiled in memory and not written to a file (in dev mode), it is also faster to generate.

Alternatively, but probably more confusingly for students, webpack-dev-server can proxy the Bones API backend.

Hot Module Replacement is awesome but requires people write the frontend of their project in a compatible way, so I don't think we need to take this feature into account when it comes to deciding Bones's build system.

However, incorporating some form of LiveReload may be a nice touch. There isn't any one canonical way to do so, though you can see some notes / one potential approach here.

omriAckley commented 7 years ago

About the refresh-wait and in-memory builds: doesn't seem high priority but I like it! Is there something we have to / should do to disable it in production?

About the proxy: are there any benefits to this?

Live reloading: love this idea. All for it.

glebec commented 7 years ago

About the refresh-wait and in-memory builds: doesn't seem high priority but I like it! Is there something we have to / should do to disable it in production?

Yes, we can do a dynamic check based on NODE_ENV which will add the middleware or not accordingly. The precise details I haven't worked out, but the middleware is explicitly intended to be dev-only so one would imagine it shouldn't be too hard to disable in production.

About the proxy: are there any benefits to this?

Eh, not really. I'm leaning away from webpack-dev-server which is too "magical" for my tastes and apparently has known issues with Node 7 besides.

Live reloading: love this idea. All for it.

Yeah, it's something I'll look into.

glebec commented 7 years ago

You know, looking more into it, I think that activating HMR for Bones might not be too tricky after all — not requiring further knowledge or special action by students. https://webpack.js.org/guides/hmr-react/

If so, this would beat LiveReload by a mile. I'm definitely going to do a proof of concept and see how it works out.

glebec commented 7 years ago

Started researching HMR but it was proving tricky in practice. Want to keep at it but for now https://github.com/FullstackAcademy/bones/commit/fa55bcf6767ddbf247a26dbeb38878147013c4d6 implements LiveReload support.

glebec commented 7 years ago

This issue was moved to FullstackAcademy/bones#72