Skip to content

Commit

Permalink
Fix browsersync building scripts only working for first run
Browse files Browse the repository at this point in the history
  • Loading branch information
rbouma2 committed Sep 4, 2019
1 parent 458fa0a commit 0b16351
Showing 1 changed file with 29 additions and 14 deletions.
43 changes: 29 additions & 14 deletions Gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var gulp = require('gulp');
var plumber = require('gulp-plumber');
var concat = require('gulp-concat');
var merge = require('merge-stream');
var sass = require('gulp-sass');
var browserSync = require('browser-sync').create();

Expand Down Expand Up @@ -32,36 +33,50 @@ gulp.task('watch', function() {
});

gulp.watch("src/scss/**/*.scss", gulp.series('sass'));
gulp.watch(scripts, gulp.series('scripts', 'reload-js'));
gulp.watch(scripts, gulp.series('scripts'));
gulp.watch("**/*.phtml").on('change', browserSync.reload);
});

gulp.task('scripts', function() {
return gulp.src(scripts)
.pipe(concat('scripts.js'))
.pipe(gulp.dest('web/js'));
var stream = gulp.src(scripts)
.pipe(concat('scripts.js'));
return stream
.pipe(gulp.dest('web/js'))
.pipe(browserSync.stream());
});

gulp.task('script-deps', function() {

for (var src in npmDependencies) {
gulp.src(src)
.pipe(gulp.dest('web/js/deps/' + npmDependencies[src]));
}
return new Promise(function (resolve) {
for (var src in npmDependencies) {
gulp.src(src)
.pipe(gulp.dest('web/js/deps/' + npmDependencies[src]));
}
resolve();
})
});

gulp.task('reload-js', function() {
browserSync.reload();
});

gulp.task('sass', function() {
return gulp.src("src/scss/style.scss")
var sassStream,
cssStream;
sassStream = gulp.src("src/scss/style.scss")
.pipe(sass({
errLogToConsole: true
}));
cssStream = gulp.src('node_modules/line-awesome/dist/css/line-awesome.css');
return merge(sassStream, cssStream)
.pipe(plumber())
.pipe(sass())
.pipe(gulp.dest("web/css"))
.pipe(gulp.dest('web/css'))
.pipe(browserSync.stream());
});

gulp.task('build', gulp.series('sass', 'script-deps', 'scripts'));
gulp.task('copy-fonts', function() {
return gulp.src('node_modules/line-awesome/dist/fonts/*')
.pipe(gulp.dest('web/fonts/'));
});
gulp.task('build', gulp.series('copy-fonts', 'sass', 'script-deps', 'scripts'));

gulp.task('default', gulp.series('build'));
gulp.task('default', gulp.series('build'));

0 comments on commit 0b16351

Please sign in to comment.