Replace watch by serve command with livereload
This commit is contained in:
parent
88d17089c3
commit
6b2bc7028b
4 changed files with 916 additions and 15 deletions
|
|
@ -100,7 +100,7 @@ Requires [Node.js](https://nodejs.org/) and [Yarn](https://yarnpkg.com/en/).
|
|||
|
||||
### Develop
|
||||
|
||||
yarn build watch
|
||||
yarn serve
|
||||
|
||||
## License
|
||||
|
||||
|
|
|
|||
29
gulpfile.js
29
gulpfile.js
|
|
@ -25,6 +25,9 @@ var sort = require('gulp-sort');
|
|||
var scanner = require('i18next-scanner');
|
||||
var jsonConcat = require('gulp-json-concat');
|
||||
var rename = require('gulp-rename');
|
||||
var browserSync = require('browser-sync');
|
||||
|
||||
const server = browserSync.create();
|
||||
|
||||
var debug = false;
|
||||
|
||||
|
|
@ -148,17 +151,37 @@ gulp.task('locales', function() {
|
|||
return gulp.src(paths.locales).pipe(gulp.dest(paths.dest + '/locales'));
|
||||
});
|
||||
|
||||
gulp.task('serve', function() {
|
||||
server.init({
|
||||
server: {
|
||||
baseDir: './'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('reload', function(done) {
|
||||
server.reload();
|
||||
done();
|
||||
});
|
||||
|
||||
gulp.task('watch', function() {
|
||||
debug = true;
|
||||
var watcher = gulp.watch(paths.scripts, gulp.series('scripts'));
|
||||
var watcher = gulp.watch(paths.scripts, gulp.series('scripts', 'reload'));
|
||||
watcher.on('change', function(event) {
|
||||
if (event.type === 'deleted') {
|
||||
delete cached.caches.scripts[event.path];
|
||||
remember.forget('scripts', event.path);
|
||||
}
|
||||
});
|
||||
gulp.watch(paths.styles, gulp.series('styles'));
|
||||
gulp.watch(paths.layersConfig, gulp.series('layers_config'));
|
||||
gulp.watch(paths.styles, gulp.series('styles', 'reload'));
|
||||
gulp.watch(paths.layersConfig, gulp.series('layers_config', 'reload'));
|
||||
gulp.watch(
|
||||
['./index.html']
|
||||
.concat(paths.images)
|
||||
.concat(paths.fonts)
|
||||
.concat(paths.locales),
|
||||
gulp.series('reload')
|
||||
);
|
||||
});
|
||||
|
||||
// Print paths to console, for manually debugging the gulp build
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
"layers": "node layers/josm/extract.js && node layers/collection/extract.js",
|
||||
"test": "gulp",
|
||||
"prettier": "prettier --write '**/*'",
|
||||
"watch": "gulp && gulp watch"
|
||||
"serve": "gulp debug && gulp serve watch"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
|
|
@ -63,6 +63,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"autoprefixer": "^8.1.0",
|
||||
"browser-sync": "^2.26.7",
|
||||
"del": "^1.1.1",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-bump": "^2.7.0",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue