Created
May 19, 2017 19:23
-
-
Save DawTaylor/c7021505386fbedf2bceb71c965b865a to your computer and use it in GitHub Desktop.
Criando um gulpfile do ZERO!!!
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
// Dependências da build | |
const gulp = require('gulp') | |
const pug = require('gulp-pug') | |
const sass = require('gulp-sass') | |
const cssMin = require('gulp-csso') | |
const browserSync = require('browser-sync').create() | |
const clean = require('gulp-clean') | |
// Compila os arquivos do PUG para HTML | |
gulp.task('html', () => { | |
return gulp.src('src/*.pug') | |
.pipe(pug()) | |
.pipe(gulp.dest('build')) | |
}) | |
// Limpa diretório build antes de iniciar a build | |
gulp.task('clean', () => { | |
return gulp.src('build/*', { read : false }) | |
.pipe(clean()) | |
}) | |
// Tarefa padrão do GULP, recebe um array de tarefas como segundo parâmetro | |
gulp.task('default', [ 'clean', 'html' ]) | |
// Compila os arquivos do PUG para servidor de dev | |
gulp.task('html:dev', () => { | |
return gulp.src('src/*.pug') | |
.pipe(pug()) | |
.pipe(gulp.dest('dev')) | |
}) | |
// Limpa diretório dev antes de iniciar o server | |
gulp.task('clean:dev', () => { | |
return gulp.src('dev/*', { read : false }) | |
.pipe(clean()) | |
}) | |
// Gulp server com browsersync | |
gulp.task('serve', [ 'clean:dev', 'html:dev' ], () => { | |
browserSync.init({ | |
server : 'dev/', | |
port : 8081, | |
open: 'local' | |
}) | |
gulp.watch('src/*.pug', [ 'html:dev' ]) | |
gulp.watch('dev/*.html').on('change', browserSync.reload) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment