From 2ffba0051acd08c167595f6c9dea26ec6338d0ef Mon Sep 17 00:00:00 2001 From: Ray Elliott Date: Fri, 1 May 2020 22:43:36 +0300 Subject: [PATCH] add browser-sync reload/inject css --- gulpfile.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 6c06e36..d8e3750 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -55,24 +55,23 @@ function scssCompile() { return src(scssSrc, { sourcemaps: true }) .pipe(sass().on("error", sass.logError)) .pipe(postcss(postcssPlugins)) - .pipe(dest(cssDest, { sourcemaps: true })); + .pipe(dest(cssDest, { sourcemaps: true })) + .pipe(server.stream()); } function htmlCompile() { - return src(htmlSrc) - .pipe(dest(htmlDest)); + return src(htmlSrc).pipe(dest(htmlDest)); } function assetCompile() { - return src(assetSrc) - .pipe(dest(assetDest)); + return src(assetSrc).pipe(dest(assetDest)); } function serve(done) { server.init({ open: false, server: { - baseDir: buildDir, + baseDir: buildDir } // or instead of server // proxy: "example.home" @@ -86,12 +85,20 @@ function reload(done) { } const jsWatch = () => - watch(jsSrc, { ignoreInitial: false }, series(jsClean, jsTranspile)); + watch(jsSrc, { ignoreInitial: false }, series(jsClean, jsTranspile, reload)); const cssWatch = () => watch(scssSrc, { ignoreInitial: false }, series(cssClean, scssCompile)); const htmlWatch = () => - watch(htmlSrc, { ignoreInitial: false }, series(htmlClean, htmlCompile)); + watch( + htmlSrc, + { ignoreInitial: false }, + series(htmlClean, htmlCompile, reload) + ); const assetWatch = () => - watch(assetSrc, { ignoreInitial: false }, series(assetClean, assetCompile)); + watch( + assetSrc, + { ignoreInitial: false }, + series(assetClean, assetCompile, reload) + ); exports.default = parallel(jsWatch, cssWatch, htmlWatch, assetWatch, serve);