Skip to content

Instantly share code, notes, and snippets.

@thomasboyt
Created February 10, 2014 23:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasboyt/8926554 to your computer and use it in GitHub Desktop.
Save thomasboyt/8926554 to your computer and use it in GitHub Desktop.
Side-by-side comparison of Grunt and Gulp configuration. Only significant difference is that `gulp-concat` doesn't generate source maps like `grunt-concat-sourcemaps`.
/* jshint node: true */
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
transpile: {
main: {
type: 'amd',
moduleName: function(path) {
return grunt.file.readJSON('package.json').name + path;
},
files: [{
expand: true,
cwd: 'src/',
src: '**/*.js',
dest: 'tmp/transpiled/'
}]
}
},
concat_sourcemap: {
main: {
src: 'tmp/transpiled/**/*.js',
dest: 'tmp/game.js',
options: {
sourceRoot: ".."
}
}
},
watch: {
main: {
files: ["src/**/*.js"],
tasks: ["default"]
}
},
connect: {
server: {
options: {
port: process.env.PORT || 8000,
hostname: '0.0.0.0',
base: '.'
}
}
}
});
grunt.registerTask("default", ["transpile", "concat_sourcemap"]);
grunt.registerTask("dev", ["default", "connect", "watch"]);
};
/* jshint node: true */
var gulp = require('gulp');
var g = require('gulp-load-plugins')();
var scriptFiles = './src/**/*.js';
gulp.task('buildJs', function() {
gulp.src('./src/**/*.js')
.pipe(g.es6ModuleTranspiler({
type: 'amd',
moduleName: function(path) {
return require('./package.json').name + '/' + path;
}
}))
.pipe(g.concat('game.js'))
.pipe(gulp.dest('./tmp'));
});
gulp.task('connect', g.connect.server({
port: process.env.PORT || 8000,
hostname: '0.0.0.0',
root: __dirname
}));
gulp.task('watch', function() {
gulp.watch(scriptFiles, ['buildJs']);
});
gulp.task('default', ['buildJs']);
gulp.task('dev', ['buildJs', 'connect', 'watch']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment