Skip to content

Instantly share code, notes, and snippets.

@pesukaru1
Created March 2, 2019 22:38
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 pesukaru1/8fd1c28f52d046ff69abc1a4809622ac to your computer and use it in GitHub Desktop.
Save pesukaru1/8fd1c28f52d046ff69abc1a4809622ac to your computer and use it in GitHub Desktop.
my gulpfile
const gulp = require('gulp');
const pug = require('gulp-pug');
const sass = require('gulp-sass');
const browsersync = require('browser-sync').create();
// Build HTML
function html() {
return gulp.
src("./pug/*.pug")
.pipe(pug({ pretty: true }))
.pipe(gulp.dest("./src/"))
.pipe(browsersync.stream());
}
// BrowserSync server
function browserSync(done) {
browsersync.init({
server: {
baseDir: "./src/"
}
});
done();
}
// BrowserSync Reload
function browserSyncReload(done) {
browsersync.reload();
done();
}
// CSS task
function css() {
return gulp
.src("./sass/*.sass")
.pipe(sass({ outputStyle: "expanded" }))
.pipe(gulp.dest("./src/css/"))
.pipe(browsersync.stream());
}
// Watch Files
function watchFiles() {
gulp.watch("./sass/**/*", css);
gulp.watch("./pug/**/*", html);
gulp.watch(
[
"./src/*.html",
"./src/css/*.css",
],
browserSyncReload);
}
// define complex task
const watch = gulp.parallel(html, watchFiles, browserSync);
// export tasks
exports.html = html;
exports.watch = watch;
exports.css = css;
exports.default = watch;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment