Created
March 2, 2019 22:38
-
-
Save pesukaru1/8fd1c28f52d046ff69abc1a4809622ac to your computer and use it in GitHub Desktop.
my gulpfile
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
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