Skip to content

Commit

Permalink
Grunt: rename browserify-watch to watch-js, add watch-css
Browse files Browse the repository at this point in the history
  • Loading branch information
longouyang committed Oct 18, 2016
1 parent be37171 commit b88fa7e
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ var fs = require('fs');

module.exports = function(grunt) {
grunt.initConfig({
clean: ['docs/webppl-editor.js', 'docs/webppl-editor.css']
clean: ['docs/webppl-editor.js', 'docs/webppl-editor.css'],
watch: {
scripts: {
files: ['src/component.css'],
tasks: ['css']
}
}
});

function browserifyArgs(args) {
Expand Down Expand Up @@ -36,8 +42,8 @@ module.exports = function(grunt) {
child_process.execSync('browserify' + browserifyArgs(arguments));
});

// TODO: watch for css changes too
grunt.registerTask('browserify-watch', 'Run the browserify task on fs changes.', function() {
// TODO: integrate watch-js and watch-css (maybe using grunt-parallel?)
grunt.registerTask('watch-js', 'Run the browserify task on fs changes.', function() {
var done = this.async();
var args = '-v' + browserifyArgs(arguments);
var p = child_process.spawn('watchify', args.split(' '));
Expand All @@ -46,6 +52,11 @@ module.exports = function(grunt) {
p.on('close', done);
});

grunt.registerTask('watch-css', 'Run the browserify task on fs changes.', function() {
grunt.task.run('watch')
});


grunt.registerTask('uglify', 'Generate "docs/webppl-editor.min.js".', function() {
child_process.execSync('uglifyjs docs/webppl-editor.js -b ascii_only=true,beautify=false > docs/webppl-editor.min.js');
});
Expand Down

0 comments on commit b88fa7e

Please sign in to comment.