Skip to content

Instantly share code, notes, and snippets.

@bermartinv
Last active September 5, 2017 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bermartinv/7c44973158af897302eed73cadbd9ef4 to your computer and use it in GitHub Desktop.
Save bermartinv/7c44973158af897302eed73cadbd9ef4 to your computer and use it in GitHub Desktop.
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