Created
October 25, 2016 23:02
-
-
Save dgramma/8f4d09f7dbd485eefcd1670fa0a3423d to your computer and use it in GitHub Desktop.
Devv.io Gulpfile for Workflow
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
// grab our packages | |
var gulp = require('gulp'), | |
sass = require('gulp-sass'), | |
autoprefixer = require('gulp-autoprefixer'), | |
sourcemaps = require('gulp-sourcemaps'), | |
concat = require('gulp-concat'), | |
uglify = require('gulp-uglify'), | |
connect = require('gulp-connect'), | |
htmlmin = require('gulp-htmlmin'), | |
open = require('gulp-open'), | |
globbing = require('gulp-css-globbing'), | |
livereload = require('gulp-livereload'); | |
// define the default task and add the watch task to it | |
gulp.task('default', ['watch']); | |
// sass compiler | |
gulp.task('devv-css', function() { | |
return gulp.src('development/scss/application.scss') | |
.pipe(sourcemaps.init()) // Process the original sources | |
.pipe(globbing({extensions: '.scss'})) | |
.pipe(sass().on('error', sass.logError)) | |
.pipe(autoprefixer({cascade: false})) | |
.pipe(sourcemaps.write()) // Add the map to modified source. | |
.pipe(gulp.dest('public/css')); | |
}); | |
gulp.task('devv-js', function() { | |
return gulp.src('development/js/**/*.js') | |
.pipe(sourcemaps.init()) | |
.pipe(concat('main.js')) | |
.pipe(uglify()) | |
.pipe(sourcemaps.write()) | |
.pipe(gulp.dest('public/js')); | |
}); | |
gulp.task('devv-vendor-js', function() { | |
return gulp.src('development/js/vendor/*.js') | |
.pipe(sourcemaps.init()) | |
.pipe(concat('vendor-bundle.js')) | |
.pipe(uglify()) | |
.pipe(sourcemaps.write()) | |
.pipe(gulp.dest('public/js')); | |
}); | |
gulp.task('devv-html', function() { | |
return gulp.src('development/html/*.html') | |
.pipe(htmlmin({collapseWhitespace: true})) | |
.pipe(gulp.dest('public')); | |
}); | |
gulp.task('open', function(){ | |
gulp.src('') | |
.pipe(open({ uri: 'http://localhost:8080'})); | |
}); | |
gulp.task('connect', function() { | |
gulp.watch('development/scss/**/*.scss', ['devv-css']); | |
gulp.watch('development/js/vendor/*.js', ['devv-vendor-js']); | |
gulp.watch(['development/js/**/*.js', '!dev/js/vendor/*.js'], ['devv-js']); | |
gulp.watch('development/html/*.html', ['devv-html']); | |
livereload.listen(); | |
gulp.watch(['public/*.html', 'public/js/*.js', 'public/css/application.css']).on('change', livereload.changed); | |
connect.server({ | |
root: 'public/', | |
host: '0.0.0.0', | |
keepalive: false, | |
livereload: true | |
}); | |
}); | |
gulp.task('default', ['devv-css', 'devv-js', 'devv-vendor-js', 'devv-html', 'connect', 'open']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment