Hacker News new | ask | show | jobs
by dmitriz 3797 days ago
Npm scripts work for very superficial tasks, but fail to deliver even for such a simple task as live reload:

- You need to run both server and watcher from the same shell, and the proposed way is to use parallelshell which is not a robust tool such as Gulp. Specifically trying npm run dev as suggested leads to some error that, after termination, leave 4 processes running in background that you have to kill manually, or else you can't access the same ports. Not fun.

- It requires to "highjack" your source files with script tags that I don't feel belong there: <script src="//localhost:9091/livereload.js"></script>

Why Gulp plugins are better?

- Fast: use streams, no temporary files. - Gulp plugins have uniform API: stream in, stream out; no massive command line options. - Convenient and expressive node-glob abstraction to select files/directories to be watched. - Less magic, more control and understanding of what is going on, less chance and dependence on bugs.

Here is the absolutely basic LiveReload setup that I wasn't able to achieve with Npm scripts:

https://github.com/dmitriz/min-server