Skip to content

Instantly share code, notes, and snippets.

@saboyutaka
Created January 30, 2018 09:55
Show Gist options
  • Save saboyutaka/4719052b88fb77966a9a56d1885fee1e to your computer and use it in GitHub Desktop.
Save saboyutaka/4719052b88fb77966a9a56d1885fee1e to your computer and use it in GitHub Desktop.
gulp
const gulp = require('gulp');
const browserSync = require('browser-sync');
const plumber = require('gulp-plumber');
const htmlhint = require('gulp-htmlhint');
const reload = browserSync.reload;
gulp.task('browser-sync', function () {
browserSync({
server: {
baseDir: './public'
},
open: 'external'
});
});
gulp.task('html', function () {
return gulp.src('./public/**/*.html')
.pipe(plumber())
.pipe(htmlhint())
.pipe(htmlhint.reporter())
.pipe(htmlhint.failReporter())
});
gulp.task('watch', function () {
gulp.watch(['./public/**/*.html'], ['html', reload]);
gulp.watch('./public/css/**').on("change", reload);
gulp.watch('./public/js/**').on("change", reload);
});
gulp.task('default', ['html', 'browser-sync', 'watch']);
{
"private": true,
"scripts": {
"gulp": "gulp"
},
"dependencies": {
"browser-sync": "^2.18.12",
"gulp": "^3.9.1",
"gulp-cached": "^1.1.1",
"gulp-html-beautify": "^1.0.1",
"gulp-htmlhint": "^0.3.1",
"gulp-plumber": "^1.1.0",
"gulp-stylefmt": "^1.1.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment