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 })
|
return src(scssSrc, { sourcemaps: true })
|
||||||
.pipe(sass().on("error", sass.logError))
|
.pipe(sass().on("error", sass.logError))
|
||||||
.pipe(postcss(postcssPlugins))
|
.pipe(postcss(postcssPlugins))
|
||||||
.pipe(dest(cssDest, { sourcemaps: true }));
|
.pipe(dest(cssDest, { sourcemaps: true }))
|
||||||
|
.pipe(server.stream());
|
||||||
}
|
}
|
||||||
|
|
||||||
function htmlCompile() {
|
function htmlCompile() {
|
||||||
return src(htmlSrc)
|
return src(htmlSrc).pipe(dest(htmlDest));
|
||||||
.pipe(dest(htmlDest));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function assetCompile() {
|
function assetCompile() {
|
||||||
return src(assetSrc)
|
return src(assetSrc).pipe(dest(assetDest));
|
||||||
.pipe(dest(assetDest));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function serve(done) {
|
function serve(done) {
|
||||||
server.init({
|
server.init({
|
||||||
open: false,
|
open: false,
|
||||||
server: {
|
server: {
|
||||||
baseDir: buildDir,
|
baseDir: buildDir
|
||||||
}
|
}
|
||||||
// or instead of server
|
// or instead of server
|
||||||
// proxy: "example.home"
|
// proxy: "example.home"
|
||||||
|
@ -86,12 +85,20 @@ function reload(done) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const jsWatch = () =>
|
const jsWatch = () =>
|
||||||
watch(jsSrc, { ignoreInitial: false }, series(jsClean, jsTranspile));
|
watch(jsSrc, { ignoreInitial: false }, series(jsClean, jsTranspile, reload));
|
||||||
const cssWatch = () =>
|
const cssWatch = () =>
|
||||||
watch(scssSrc, { ignoreInitial: false }, series(cssClean, scssCompile));
|
watch(scssSrc, { ignoreInitial: false }, series(cssClean, scssCompile));
|
||||||
const htmlWatch = () =>
|
const htmlWatch = () =>
|
||||||
watch(htmlSrc, { ignoreInitial: false }, series(htmlClean, htmlCompile));
|
watch(
|
||||||
|
htmlSrc,
|
||||||
|
{ ignoreInitial: false },
|
||||||
|
series(htmlClean, htmlCompile, reload)
|
||||||
|
);
|
||||||
const assetWatch = () =>
|
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);
|
exports.default = parallel(jsWatch, cssWatch, htmlWatch, assetWatch, serve);
|
||||||
|
|
Loading…
Reference in New Issue