Skip to content

Instantly share code, notes, and snippets.

@iamphill

iamphill/gulpfile.js

Last active Aug 29, 2015
Embed
What would you like to do?
First gulpfile ever made for some awesome-y projects
var gulp = require('gulp'),
sass = require('gulp-sass'),
watch = require('gulp-watch'),
to5 = require('gulp-6to5'),
browserify = require('gulp-browserify'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
runSequence = require('run-sequence');
gulp.task('watch', function () {
// Watch sass files
// Then run the sass task
watch('./css/lib/**/*.scss', function () {
gulp.start('sass');
});
// Watch JS files
// Then run scripts task
// This compiles es6 to es5
// Then browserify
// Then uglify
watch('./js/lib/**/*.js', function () {
gulp.start('scripts');
});
});
gulp.task('6to5', function () {
return gulp.src('./js/lib/**/*.js')
.pipe(to5())
.pipe(gulp.dest('./js/compiled'));
});
gulp.task('browserify', function () {
return gulp.src('./js/compiled/app.js')
.pipe(browserify())
.pipe(gulp.dest('./js/dist'));
});
gulp.task('uglify', function () {
return gulp.src('./js/dist/app.js')
.pipe(uglify())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('./js/dist'));
});
gulp.task('sass', function () {
gulp.src('./css/lib/style.scss')
.pipe(sass({
outputStyle: 'compressed'
}))
.pipe(gulp.dest('./css/dist'));
});
gulp.task('scripts', function (cb) {
runSequence('6to5', 'browserify', 'uglify', cb);
});
gulp.task('default', ['watch']);
{
"name": "gulp-test",
"version": "1.0.0",
"description": "",
"author": "Phil Hughes <me@iamphill.com>",
"devDependencies": {
"gulp": "^3.8.11",
"gulp-6to5": "^3.0.0",
"gulp-browserify": "^0.5.1",
"gulp-rename": "^1.2.0",
"gulp-sass": "^1.3.2",
"gulp-uglify": "^1.1.0",
"gulp-watch": "^4.1.1",
"run-sequence": "^1.0.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.