Skip to content

Instantly share code, notes, and snippets.

@bermartinv
Last active Sep 5, 2017
Embed
What would you like to do?
my workflow
var gulp = require('gulp');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var cssnano = require('gulp-cssnano');
var imagemin = require('gulp-imagemin');
var autoprefixer = require('gulp-autoprefixer');
var htmlmin = require('gulp-htmlmin');
var browserSync = require('browser-sync').create();
gulp.task('default', ['css','javascript'], function() {
browserSync.init({
server: "./app"
});
gulp.watch('app/js/*.js',["javascript"]).on('change', browserSync.reload);
gulp.watch('scss/**/*.scss',['css']);
gulp.watch("app/*.html").on('change', browserSync.reload);
gulp.watch('./*.html',['html']);
});
gulp.task('html', function() {
return gulp.src('./*.html')
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest('app'));
});
gulp.task('imagenes', function(){
gulp.src('images/*')
.pipe(imagemin())
.pipe(gulp.dest('app/images'));
});
gulp.task('javascript', function () {
gulp.src('app/js/*.js')
.pipe(uglify())
.pipe(gulp.dest('app/js/dist'))
});
/* FUncion sass */
gulp.task('css',function(){
return gulp.src('scss/**/*.scss')
.pipe(sass())
.pipe(cssnano())
.pipe(autoprefixer({
browsers: ['last 10 versions'],
cascade: false
}))
.pipe(gulp.dest('app/css'))
.pipe(browserSync.stream());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment