Closed asclines closed 7 years ago
@asclines Are you suggesting that we have Webpack bundle the back end together with the front end, or that we have the back end in its own bundle?
I agree with changing the NPM commands.
"start": "npm-run-all start-api start-app",
"start-app": "webpack-dev-server --env=dev",
"start-api": "node server.js",
start-app
is for development, rather than deployment. We could change start
to node server.js
and that would serve our purposes. These changes would allow us to eliminate start-api
entirely.
@NilsG-S I'm not 100% sure as I am not that familiar with Webpack, I was hoping you could take this task on. From my understanding, it wouldn't make much sense to have a Webpack bundle for both the front end source code and the back end source code. But rather two bundles, one for building the front end and one for hosting the build with the back end.
@asclines Your understanding is correct. I can look into setting Webpack up to build the back end as well. There are other advantages beyond non-relative pathing, like hot module replacement
I like it, please keep me updated on your progress.
I'm looking into using nodemon
to actually restart the server. As it is, Webpack with --watch
enabled will rebundle the code when it changes, but the bundle won't be executed. nodemon
would watch the bundle and restart it when it is updated.
@NilsG-S is there more to this issue that needs handling or can we mark this as resolved?
Not that I can think of. Closing
These changes revolve around webpack. Is it possible to use webpack to build the backend as well? Seeing as they will be deployed together anyways. This will solve two problems I see:
In doing so I propose these changes to the NPM commands.
npm start
: Would start the backend and serve up the frontendnpm build
: Would build the front endGoing forward I do not see a reason to have two
npm start-*
s as starting the frontend without the backend would be pointless.This is all done if the plan to make this one app, not two projects in one repo.