add browser-sync reload/inject css

This commit is contained in:
Ray Elliott 2020-05-01 22:43:36 +03:00
parent 4ee08d8a8b
commit 2ffba0051a
1 changed files with 16 additions and 9 deletions

View File

@ -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);