Created
February 27, 2015 14:25
-
-
Save thomastuts/a4dafc20d49662e4e13a to your computer and use it in GitHub Desktop.
Splitting up Gulp tasks in separate files
This file contains hidden or 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
// gulpfile.js | |
var gulp = require('gulp'); | |
var requireDir = require('require-dir'); | |
var tasks = requireDir('./tasks'); | |
gulp.task('sass', tasks.sass); | |
gulp.task('serve:dev', tasks.serve.dev); | |
gulp.task('serve:dist', tasks.serve.dist); | |
gulp.task('default', ['sass', 'serve:dev']); |
This file contains hidden or 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
// tasks/sass.js | |
var gulp = require('gulp'); | |
var sass = require('gulp-sass'); | |
module.exports = function () { | |
return gulp.src('./scss/app.scss') | |
.pipe(sass()) | |
.pipe(gulp.dest('./css')); | |
}; |
This file contains hidden or 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
// tasks/serve.js | |
var browserSync = require('browser-sync'); | |
module.exports = { | |
dev: function () { | |
browserSync({ | |
port: 1337, | |
notify: false, | |
server: { | |
baseDir: ['app', './'] | |
} | |
}); | |
}, | |
dist: function () { | |
browserSync({ | |
port: 1338, | |
notify: false, | |
server: { | |
baseDir: ['dist', './'] | |
} | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment