add browser-sync reload/inject css
This commit is contained in:
parent
4ee08d8a8b
commit
2ffba0051a
25
gulpfile.js
25
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);
|
||||
|
|
Loading…
Reference in New Issue