Created
December 29, 2013 14:37
-
-
Save Sigmus/8171005 to your computer and use it in GitHub Desktop.
Migrating some configuration from Gruntfile.js to gulpfile.js
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
var gulp = require('gulp'); | |
var browserify = require('gulp-browserify'); | |
var less = require('gulp-less'); | |
var concat = require('gulp-concat'); | |
var jshint = require('gulp-jshint'); | |
var outDir = null; | |
var sources = { | |
scripts: './app/scripts/**/*.js', | |
less: './app/styles/**/*.less', | |
copy: [ | |
{src: './app/templates/*', dest: ''}, | |
{src: './app/images/*', dest: 'images'} | |
], | |
browserify: './app/scripts/main.js' | |
}; | |
gulp.task('default', function () { | |
gulp.run('temp'); | |
}); | |
gulp.task('temp', function() { | |
outDir = './temp'; | |
gulp.run('copy', 'less', 'jshint', 'browserify'); | |
gulp.watch(sources.less, function() { | |
gulp.run('less'); | |
}); | |
sources.copy.forEach(function(item) { | |
gulp.watch(item.src, function() { | |
gulp.run('copy'); | |
}); | |
}); | |
gulp.watch(sources.scripts, function() { | |
gulp.run('jshint'); | |
}); | |
gulp.watch(sources.browserify, function() { | |
gulp.run('browserify'); | |
}); | |
}); | |
gulp.task('copy', function () { | |
sources.copy.forEach(function(item) { | |
gulp.src(item.src) | |
.pipe(gulp.dest(outDir + '/' + item.dest)) | |
}); | |
}); | |
gulp.task('less', function () { | |
gulp.src(sources.less) | |
.pipe(less({compress: false})) | |
.pipe(gulp.dest(outDir + '/styles')); | |
}); | |
gulp.task('jshint', function() { | |
gulp.src(sources.scripts) | |
.pipe(jshint()) | |
.pipe(jshint.reporter('jshint-stylish')) | |
}); | |
gulp.task('browserify', function() { | |
gulp.src(sources.browserify) | |
.pipe(browserify()) | |
.pipe(concat('main.js')) | |
.pipe(gulp.dest(outDir + '/scripts/')) | |
}); |
- I'm developing / serving the app at temp. Each time some html file or image gets updated it's copied
- Will look into multiple globs, thanks!
- It should. This script is being modified as a developed my app. There is also going to be a build task. Not sure which one will be the default, so this default task is an "alias" or a "placeholder". But you are correct.
@Sigmus right now it seems like half of your code is setting up the watches. I think we can smooth that over quite a bit - I just opened gulpjs/gulp#76 about it
@contra Cool!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Sigmus