Last active
December 21, 2015 14:39
-
-
Save rmariuzzo/6321203 to your computer and use it in GitHub Desktop.
A simple NodeJS script to watch for changes in a specific less and js file. When changes detected then bash script will be executed for to compile less files and to uglify js scripts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear | |
curdir="${0%/*}" | |
uglifyjs -v \ | |
$curdir/jquery/jquery.js \ | |
$curdir/twbs/js/bootstrap.js \ | |
$curdir/superfish/superfish.js \ | |
$curdir/site/js/site.js \ | |
-o $curdir/../../js/app.js \ | |
-m | |
echo 'JS files compiled successfully!' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear | |
curdir="${0%/*}" | |
lessc -x \ | |
$curdir/site/less/site.less \ | |
$curdir/../../style.css | |
echo 'LESS files compiled successfully!' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('shelljs/global'); | |
var fs = require('fs'), | |
path = require('path'); | |
var curdir = path.resolve(__dirname), | |
jsCompiling = false, | |
lessCompiling = false; | |
fs.watch(curdir + '/site/less/site.less', function(event, filename) { | |
if (event === 'change' && ! lessCompiling) { | |
echo('Change detected: ' + filename); | |
lessCompiling = true; | |
exec('sh ' + curdir + '/compile-less.sh', function() { | |
lessCompiling = false; | |
}); | |
} | |
}); | |
fs.watch(curdir + '/site/js/site.js', function(event, filename) { | |
if (event === 'change' && ! jsCompiling) { | |
echo('Change detected: ' + filename); | |
jsCompiling = true; | |
exec('sh ' + curdir + '/compile-js.sh', function() { | |
jsCompiling = false; | |
}); | |
} | |
}); | |
echo('Watching for changes...') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment