Created
May 2, 2014 23:58
-
-
Save jessehattabaugh/5f6a275a160b339e35a7 to your computer and use it in GitHub Desktop.
build script
This file contains 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
#!/usr/bin/env node | |
"use strict"; | |
var fs = require('fs'), | |
gw = require('globwatcher').globwatcher; | |
var cssw = gw('./source/*.styl', {persistent: true}); | |
cssw.on('added', function (filename) { | |
console.log(filename + ' added'); | |
buildStylus(filename); | |
}); | |
cssw.on('changed', function (filename) { | |
console.log(filename + ' changed'); | |
buildStylus(filename); | |
}); | |
cssw.ready.then(function() { | |
console.log('watching for changes to stylus'); | |
}); | |
var stylus = require('stylus'), | |
nib = require('nib'); | |
function buildStylus(filename) { | |
fs.readFile(filename, 'utf8', function (err, data) { | |
if (err) console.error(err); | |
stylus(data) | |
.use(nib()) | |
.render(function (err, css) { | |
if (err) return console.error(err); | |
fs.writeFile('./build/www/index.css', css, function (err) { | |
if (err) return console.error(err); | |
console.log('CSS compiled'); | |
}); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment