Created
February 10, 2014 23:44
-
-
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`.
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
/* 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"]); | |
}; |
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
/* 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