Skip to content

Commit

Permalink
Grunt: some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
longouyang committed Dec 8, 2016
1 parent 9116fba commit 0136687
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var fs = require('fs');

module.exports = function(grunt) {
grunt.initConfig({
clean: ['docs/webppl-editor.js', 'docs/webppl-editor.css'],
clean: ['docs/webppl-editor.*'],
watch: {
scripts: {
files: ['src/component.css'],
Expand All @@ -16,18 +16,14 @@ module.exports = function(grunt) {
}
});

function browserifyArgs(args) {
return ' -t [babelify --presets [react] ] src/index.js -o docs/webppl-editor.js';
}

grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-watch');

grunt.registerTask('default', ['bundle']);

grunt.registerTask('bundle', 'Create browser bundle (= browserify + css)', function() {
var taskArgs = (arguments.length > 0) ? ':' + _.toArray(arguments).join(':') : '';
grunt.task.run('browserify' + taskArgs, 'css');
grunt.task.run('css', 'browserify' + taskArgs);
});

grunt.registerTask('css', 'Concatenate css files', function() {
Expand All @@ -38,6 +34,10 @@ module.exports = function(grunt) {
fs.writeFileSync('docs/webppl-editor.css', cssSource)
})

function browserifyArgs(args) {
return ' -t [babelify --presets [react] ] src/index.js -o docs/webppl-editor.js';
}

grunt.registerTask('browserify', 'Generate "docs/webppl-editor.js".', function() {
child_process.execSync('browserify' + browserifyArgs(arguments));
});
Expand All @@ -52,11 +52,10 @@ module.exports = function(grunt) {
p.on('close', done);
});

grunt.registerTask('watch-css', 'Run the browserify task on fs changes.', function() {
grunt.registerTask('watch-css', 'Run the css 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 0136687

Please sign in to comment.