简体   繁体   English

让gulp-file-include和browser-sync一起工作

[英]Getting gulp-file-include and browser-sync to work together

I read in a blog you could use gulp-file-include to include .html files, It works but the code below winds up overwriting the include markup in the html... 我在博客中读到你可以使用gulp-file-include来包含.html文件,它可以工作,但下面的代码最终会覆盖html中的include标记...

You might think why don't I have gulp-file-include spit out to another destination folder? 您可能会想为什么我没有gulp-file-include吐出到另一个目标文件夹? Reason being is then I can't get browser-sync to refresh the browser after that. 原因是那时我无法通过浏览器同步来刷新浏览器。 Essentially this link is illustrating my problem... 基本上这个链接说明了我的问题......

Looks like there is supposed to be another 'output' folder which will be distilling all the includes into a new .index.html file 看起来应该有另一个'output'文件夹,它将所有包含提取到一个新的.index.html文件中

I know I could just open up the file which is receiving the includes and then browserSync would work, but isn't that an extra step? 我知道我可以打开接收包含的文件,然后browserSync可以工作,但这不是一个额外的步骤吗?

Please ask questions as this seems very inceptionesque! 请问问题,因为这看起来很神奇!

gulp.task('fileinclude', function() {
  gulp.src('builds/development/*.html')
  .pipe(fileinclude())
  .pipe(gulp.dest('builds/development/'));
});

Turns out I hadn't included the fileinclude in my watch task... 结果我没有将fileinclude包含在我的watch任务中......

For anyone who wants to check out what I ended up with check out my gist... 对于任何想要查看我最终结果的人,请查看我的要点...

https://gist.github.com/antonioOrtiz/2bf2e27b8e0a23115034 https://gist.github.com/antonioOrtiz/2bf2e27b8e0a23115034

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM