Browser-Sync loop

minor fix to prevent Browser-Sync loop
This commit is contained in:
Johan Nielsen 2018-07-16 13:57:36 +02:00 committed by GitHub
parent 1829f2059c
commit 41416d61c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 10 deletions

View File

@ -36,8 +36,8 @@ function scss( ) {
exports.scss = scss; exports.scss = scss;
// Minify CSS // Minify CSS
function minifycss( done ) { function minifycss( ) {
gulp.src( paths.css + '/theme.css' ) return gulp.src( paths.css + '/theme.css' )
.pipe( sourcemaps.init( { loadMaps: true } ) ) .pipe( sourcemaps.init( { loadMaps: true } ) )
.pipe( cleanCSS( { compatibility: '*' } ) ) .pipe( cleanCSS( { compatibility: '*' } ) )
.pipe( rename( { suffix: '.min' } ) ) .pipe( rename( { suffix: '.min' } ) )
@ -50,8 +50,6 @@ function minifycss( done ) {
.pipe( rename( { suffix: '.min' } ) ) .pipe( rename( { suffix: '.min' } ) )
.pipe( sourcemaps.write( './' ) ) .pipe( sourcemaps.write( './' ) )
.pipe( gulp.dest( paths.css ) ); .pipe( gulp.dest( paths.css ) );
done();
}; };
exports.minifycss = minifycss; exports.minifycss = minifycss;
@ -65,7 +63,9 @@ function scripts( done ) {
paths.dev + '/js/skip-link-focus-fix.js', paths.dev + '/js/skip-link-focus-fix.js',
// Adding currently empty javascript file to add on for your own themes´ customizations // Adding currently empty javascript file to add on for your own themes´ customizations
// Please add any customizations to this .js file only! // Please add any customizations to this .js file only!
paths.dev + '/js/custom-javascript.js' paths.dev + '/js/custom-javascript.js',
paths.dev + '/js/search.js'
]; ];
gulp.src( scripts ) gulp.src( scripts )
@ -76,8 +76,8 @@ function scripts( done ) {
.pipe( concat( 'theme.min.js' ) ) .pipe( concat( 'theme.min.js' ) )
.pipe( uglify() ) .pipe( uglify() )
.pipe( gulp.dest( paths.js ) ); .pipe( gulp.dest( paths.js ) );
revision();
done();
} }
exports.scripts = scripts; exports.scripts = scripts;
@ -148,11 +148,11 @@ gulp.task( 'clean-dist', function() {
function revision( done ) { function revision( done ) {
// by default, gulp would pick `assets/css` as the base, // by default, gulp would pick `assets/css` as the base,
// so we need to set it explicitly: // so we need to set it explicitly:
gulp.src([paths.css + '/theme.min.css', paths.js + '/theme.min.js'], {base: './'}) return gulp.src([paths.css + '/theme.min.css', paths.js + '/theme.min.js'], {base: './'})
.pipe(rev()) .pipe(rev())
.pipe(gulp.dest('./')) // write rev'd assets to build dir .pipe(gulp.dest('./')) // write rev'd assets to build dir
.pipe(rev.manifest()) .pipe(rev.manifest())
.pipe(revDel({dest: './'})) .pipe(revDel({dest: './', force: true}))
.pipe(gulp.dest('./')); // write manifest to build dir .pipe(gulp.dest('./')); // write manifest to build dir
done(); done();
}; };
@ -181,8 +181,8 @@ function reload( done ){
// BrowserSync main task // BrowserSync main task
gulp.task( 'watch-bs', function( done ) { gulp.task( 'watch-bs', function( done ) {
browserSync.init( cfg.browserSyncWatchFiles, cfg.browserSyncOptions ); browserSync.init( cfg.browserSyncWatchFiles, cfg.browserSyncOptions );
gulp.watch( paths.sass + '/**/*.scss', gulp.series(scss, minifycss, revision, reload) ); gulp.watch( paths.sass + '/**/*.scss', gulp.series( scss, minifycss, revision, reload ) );
gulp.watch( [paths.dev + '/js/**/*.js', 'js/**/*.js', '!js/theme.js', '!js/theme.min.js'], gulp.series( scripts, revision, reload ) ); gulp.watch( [paths.dev + '/js/**/*.js', 'js/**/*.js', '!js/theme.js', '!js/theme.min.js'], gulp.series( scripts, reload ) );
//Inside the watch task. //Inside the watch task.
gulp.watch( paths.imgsrc + '/**', gulp.series( imagemin, reload ) ); gulp.watch( paths.imgsrc + '/**', gulp.series( imagemin, reload ) );