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

Is there a way to run everything in watch mode? #8

Closed
grug opened this issue Oct 12, 2017 · 1 comment
Closed

Is there a way to run everything in watch mode? #8

grug opened this issue Oct 12, 2017 · 1 comment

Comments

@grug
Copy link

grug commented Oct 12, 2017

Hi there,

Is there a way to run this project with one command that does the following:

  • Builds everything
  • Runs the node service
  • Watches the client side code for changes and triggers a build when changes are detected
  • Watches the server side code for changes and triggers a build when changes are detected
@styfle
Copy link
Owner

styfle commented Oct 12, 2017

Good question! 👍

The goal of this project is to demonstrate React SSR with TypeScript and try to keep the dependencies to the bare minimum. Earlier this year I switched from browserify to webpack since that's what seems to be used more in the wild.

I do have a npm run watch that will almost work because the code will rebuild but it won't automatically restart the server. So you will get react warnings that the server side does not match the client side.

However, you can get really close to what you want with no warnings using nodemon.

  1. Opening a terminal and exec npm run watch
  2. Open another terminal and exec npx nodemon (assuming latest npm that ships with npx)
  3. Editing a file and save
  4. Refresh browser
  5. It should pick up the changes, woohoo 🎉

Now there are tools to skip step 4 and auto-refresh the browser for you such as webpack dev server with hot module reloading (HMR). This example might work. Also npm-run-all might work.

I would be happy to accept a PR if you would like to implement 😃 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants