我的 gulp watch 任务配置如下:
gulp.task('watch', function() {
gulp.watch('js/*.js', ['scripts']);
gulp.watch('jade/*.jade', ['jade']);
gulp.watch('stylus/*.styl', ['stylus'])
gulp.watch('img/*', ['images']);
});
除了一件事之外,一切都轻而易举:更新我的 svg 样式时,它不是通过 livereload 来实现的(我使用 gulp-connect 插件),但是当我手动重新加载时可以工作......我还注意到对.jade 文件确实更新了 svg 样式,因此这个小解决方法:
gulp.task('watch', function() {
gulp.watch('js/*.js', ['scripts']);
gulp.watch('jade/*.jade', ['jade']);
gulp.watch('stylus/*.styl', ['stylus', 'jade']) << workaround to force livereloading the html as well.
gulp.watch('img/*', ['images']);
});
我怀疑这与嵌入 svg 的对象标签有关,但不能确定。使用此链接,css 样式也被硬编码在 svg 本身中:
<?xml-stylesheet href="../css/style.css" type="text/css"?>
我可以通过这个小技巧让它工作,但你知道,这对于为什么会发生这一切并不是很有启发性......
提前感谢任何可以向我解释这一点的人。