Skip to content

Instantly share code, notes, and snippets.

@DawTaylor
Created May 19, 2017 19:23
Show Gist options
  • Save DawTaylor/c7021505386fbedf2bceb71c965b865a to your computer and use it in GitHub Desktop.
Save DawTaylor/c7021505386fbedf2bceb71c965b865a to your computer and use it in GitHub Desktop.
Criando um gulpfile do ZERO!!!
// 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