TTUSDC / cpceed-webapp

CPCEED Web App
https://ttusdc.github.io/cpceed-webapp/
3 stars 0 forks source link

Logger and Webpack #15

Closed NilsG-S closed 7 years ago

NilsG-S commented 7 years ago

One thing this PR does is change the logger to loglevel, which can be used easily by both the front end and the back end.

But importantly, it also adds Webpack bundling to the back end. This allows for absolute paths in imports and hot module replacement. The command for development on the API is now npm run start-api, which bundles everything and automatically starts the server. When files change the old instance of the server is killed and a new one is started. The command for deployment is npm run start, which bundles the front end and the back end, before starting the server (this time without hot module replacement).

EDIT

Note: Using absolute paths in a file will break the tests corresponding to it. Tests will have to be bundled from now on. I didn't implement this functionality in order to get this PR out more quickly, but I can do so.

asclines commented 7 years ago

@NilsG-S How difficult will it be to bundle the tests? And what other side effects from that might be there be? i.e. test output, etc..

NilsG-S commented 7 years ago

The test output shouldn't be affected. I'm going to go ahead and try to bundle the tests tonight, so we'll see about difficulty.

NilsG-S commented 7 years ago

@asclines What do you mean by "different"? I ended up replacing my original observer idea with a Webpack plugin: webpack/webpack-watch-plugin.js. It uses Webpack hooks to detect when a bundle is about to be emitted and kills the server. Then once the new bundle is emitted, it restarts the server.

asclines commented 7 years ago

@NilsG-S we can continue this conversation in Slack after the current one