Fix gulp file reload
This commit is contained in:
parent
1d92fea37a
commit
a0011ec660
1 changed files with 18 additions and 8 deletions
26
gulpfile.js
26
gulpfile.js
|
@ -15,6 +15,14 @@ var buffer = require('vinyl-buffer');
|
||||||
var through = require('through2')
|
var through = require('through2')
|
||||||
// todo: rollup for d3 & possibly jsonld
|
// todo: rollup for d3 & possibly jsonld
|
||||||
|
|
||||||
|
|
||||||
|
const server = browserSync.create();
|
||||||
|
|
||||||
|
function reload(done) {
|
||||||
|
server.reload();
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
|
||||||
var paths = {
|
var paths = {
|
||||||
"styles": {
|
"styles": {
|
||||||
"src": "./src/scss/*.scss",
|
"src": "./src/scss/*.scss",
|
||||||
|
@ -32,11 +40,12 @@ var paths = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
gulp.task('styles', function() {
|
gulp.task('styles', function(done) {
|
||||||
gulp.src(paths.styles.src, { sourcemaps: true })
|
// console.log(done);
|
||||||
|
return gulp.src(paths.styles.src, { sourcemaps: true })
|
||||||
.pipe(sass().on('error', sass.logError))
|
.pipe(sass().on('error', sass.logError))
|
||||||
.pipe(gulp.dest(paths.styles.dest))
|
.pipe(gulp.dest(paths.styles.dest))
|
||||||
.pipe(browserSync.reload({ stream: true }));
|
.pipe(server.reload({ stream: true }));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,6 +64,7 @@ gulp.task('scripts', function() {
|
||||||
// .pipe(sourcemaps.write('maps'))
|
// .pipe(sourcemaps.write('maps'))
|
||||||
.pipe(sourcemaps.write(''))
|
.pipe(sourcemaps.write(''))
|
||||||
.pipe(gulp.dest(paths.scripts.d3destDir)) // save .min.js
|
.pipe(gulp.dest(paths.scripts.d3destDir)) // save .min.js
|
||||||
|
// .pipe(server.reload())
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('d3', function() {
|
gulp.task('d3', function() {
|
||||||
|
@ -84,22 +94,22 @@ gulp.task('jsonld', function(){
|
||||||
|
|
||||||
var watchStylesAndScripts = function() {
|
var watchStylesAndScripts = function() {
|
||||||
gulp.watch(paths.styles.src, gulp.series('styles'));
|
gulp.watch(paths.styles.src, gulp.series('styles'));
|
||||||
gulp.watch(paths.scripts.src,gulp.series('scripts', browserSync.reload));
|
gulp.watch(paths.scripts.src,gulp.series('scripts', reload));
|
||||||
gulp.watch(paths.scripts.d3src,gulp.series('d3', browserSync.reload));
|
gulp.watch(paths.scripts.d3src,gulp.series('d3', reload));
|
||||||
gulp.watch([paths.data.src], gulp.series('jsonld', browserSync.reload));
|
gulp.watch([paths.data.src], gulp.series('jsonld', reload));
|
||||||
}
|
}
|
||||||
|
|
||||||
gulp.task('watch', watchStylesAndScripts);
|
gulp.task('watch', watchStylesAndScripts);
|
||||||
|
|
||||||
// watch files for changes and reload
|
// watch files for changes and reload
|
||||||
gulp.task('serve', function() {
|
gulp.task('serve', function() {
|
||||||
browserSync({
|
server.init({
|
||||||
server: {
|
server: {
|
||||||
baseDir: '.'
|
baseDir: '.'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.watch(['index.html','rubenvandeven.jsonld'], browserSync.reload({stream: true}));
|
gulp.watch(['index.html','rubenvandeven.jsonld'], reload);
|
||||||
watchStylesAndScripts();
|
watchStylesAndScripts();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue