Skip to content

Commit

Permalink
improve(dev): speed up css/js sync in watch mode
Browse files Browse the repository at this point in the history
  • Loading branch information
xyhp915 authored and tiensonqin committed Dec 27, 2021
1 parent 43823ae commit c0ce1f5
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions gulpfile.js
Expand Up @@ -49,18 +49,25 @@ const common = {
return gulp.watch(resourceFilePath, { ignoreInitial: true }, common.syncResourceFile)
},

syncStatic () {
syncAllStatic () {
return gulp.src([
outputFilePath,
'!' + path.join(outputPath, 'node_modules/**')
]).pipe(gulp.dest(publicStaticPath))
},

keepSyncStatic () {
syncJS_CSSinRt () {
return gulp.src([
path.join(outputPath, 'js/**'),
path.join(outputPath, 'css/**')
], { base: outputPath }).pipe(gulp.dest(publicStaticPath))
},

keepSyncStaticInRt () {
return gulp.watch([
path.join(outputPath, 'js/**'),
path.join(outputPath, 'css/**')
], { ignoreInitial: true }, common.syncStatic)
], { ignoreInitial: true }, common.syncJS_CSSinRt)
}
}

Expand Down Expand Up @@ -109,5 +116,6 @@ exports.electronMaker = async () => {
}

exports.clean = common.clean
exports.watch = gulp.series(common.syncResourceFile, common.syncStatic, gulp.parallel(common.keepSyncResourceFile, css.watchCSS, common.keepSyncStatic))
exports.watch = gulp.series(common.syncResourceFile, common.syncAllStatic,
gulp.parallel(common.keepSyncResourceFile, css.watchCSS, common.keepSyncStaticInRt))
exports.build = gulp.series(common.clean, common.syncResourceFile, css.buildCSS)

0 comments on commit c0ce1f5

Please sign in to comment.