Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
gruntfile
var fs = require('fs');
var path = require('path');
var sweet = require('sweet.js');
module.exports = function(grunt) {
grunt.initConfig({
sweetjs: {
options: {
modules: ['es6-macros'],
sourceMap: true,
nodeSourceMapSupport: true
},
server: {
files: [{
expand: true,
cwd: 'src/',
src: ['**/*.js'],
dest: 'build/'
}]
},
client: {
options: {
nodeSourceMapSupport: false
},
files: [{
expand: true,
cwd: 'static/js/',
src: ['**/*.js', '!lib/**/*.js'],
dest: 'static/js-build/'
}]
}
},
copy: {
client: {
files: [{
expand: true,
cwd: 'static/js/',
src: ['lib/**/*.js'],
dest: 'static/js-build/'
}]
}
},
watch: {
options: {
nospawn: true
},
server_js: {
files: ['src/**/*.js'],
tasks: ['sweetjs:server']
},
client_js: {
files: ['static/js/**/*.js'],
tasks: ['sweetjs:client']
}
}
});
grunt.event.on('watch', function(action, filepath, target) {
if(action == 'changed') {
var dest, cmd;
if(target == 'server_js') {
dest = filepath.replace(/^src/, 'build');
cmd = 'sweetjs.server';
}
else {
dest = filepath.replace(/^static\/js/, 'static/js-build');
cmd = 'sweetjs.client';
}
grunt.config.set(cmd + '.src', [filepath]);
grunt.config.set(cmd + '.dest', dest);
}
else if(action == 'deleted') {
// remove files in build
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-sweet.js');
grunt.registerTask('default', ['sweetjs', 'copy']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.