Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automate this browserify command whenever js file is changed

Whenever I change function.js, I have to manually run the command below to browserify function.js into a bundle.js

$ browserify function.js --standalone function > bundle.js

How can this step be automated such that the command is run automatically in the background whenever function.js is modified?

I am using node.js v6.9 with Webstorm 2016.2 on Windows 10.

like image 984
guagay_wk Avatar asked Dec 28 '25 08:12

guagay_wk


1 Answers

This is very easy with watchify, Just install npm i -D watchify

then update your 'package.json' file with a command "watch" : "npx watchify <source>.js -o <output>.js"

And your are ready to go with just running your npm command npm run watch.

like image 133
Pranta Saha Avatar answered Dec 31 '25 00:12

Pranta Saha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!