Skip to content
This repository has been archived by the owner on Nov 1, 2018. It is now read-only.

How to watch and run the compiled scripts in /dist? #1

Closed
coodoo opened this issue Jan 23, 2017 · 2 comments
Closed

How to watch and run the compiled scripts in /dist? #1

coodoo opened this issue Jan 23, 2017 · 2 comments
Labels

Comments

@coodoo
Copy link

coodoo commented Jan 23, 2017

Since babel:watch will continually output scripts whenever the source changed, just wondering how do you make node to pick up those changes?

@jsynowiec
Copy link
Owner

Hi, thanks for asking.

You have a range of possible solutions. For example:

  1. You can use a tool called nodemon or node-supervisor to watch and reload your compiled code,
  2. You can use a more robust version of 1 - a full-fledged process monitor like pm2,
  3. You can use babel-node with nodemon to watch and reload your source without outputting compiled code,
  4. You can use a faster version of 3 - babel-watch,

If you want to compile your sources using babel:watch command and then reload your application whenever your changes are compiled, use the nodemon:

  1. Install nodemon globally: npm install -g nodemon
  2. Run your compiled scripts using nodemon: nodemon . /dist/main.js

If you just want to reload your code on every change, you can skip the compiling and use the babel-watch to monitor your source code and "compile in-memory":

  1. Install it as a dev dependancy: yarn add --dev babel-watch (or npm install -D babel-watch)
  2. Add a new script to your package.json file:
  "scripts": {
    "start:dev": "babel-watch dist/main.js"
  }
  1. Start using yarn run start:dev (or npm run start:dev)

@coodoo
Copy link
Author

coodoo commented Jan 24, 2017

Thanks for pointing out to the right direction, babel-watch looks like a fantastic solution to the problem, which provides watch, transpilation and reload in one go!

@coodoo coodoo closed this as completed Jan 24, 2017
phra referenced this issue in phra/node-flowtype-boilerplate May 3, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants