• <i id='Uw0Iq'><tr id='Uw0Iq'><dt id='Uw0Iq'><q id='Uw0Iq'><span id='Uw0Iq'><b id='Uw0Iq'><form id='Uw0Iq'><ins id='Uw0Iq'></ins><ul id='Uw0Iq'></ul><sub id='Uw0Iq'></sub></form><legend id='Uw0Iq'></legend><bdo id='Uw0Iq'><pre id='Uw0Iq'><center id='Uw0Iq'></center></pre></bdo></b><th id='Uw0Iq'></th></span></q></dt></tr></i><div id='Uw0Iq'><tfoot id='Uw0Iq'></tfoot><dl id='Uw0Iq'><fieldset id='Uw0Iq'></fieldset></dl></div>

    <small id='Uw0Iq'></small><noframes id='Uw0Iq'>

    • <bdo id='Uw0Iq'></bdo><ul id='Uw0Iq'></ul>

    1. <legend id='Uw0Iq'><style id='Uw0Iq'><dir id='Uw0Iq'><q id='Uw0Iq'></q></dir></style></legend><tfoot id='Uw0Iq'></tfoot>

        gulp:如何在不刷新的情况下更新浏览器(仅适用于

        时间:2023-05-29
          <tbody id='SfqiU'></tbody>
        <legend id='SfqiU'><style id='SfqiU'><dir id='SfqiU'><q id='SfqiU'></q></dir></style></legend>
      1. <i id='SfqiU'><tr id='SfqiU'><dt id='SfqiU'><q id='SfqiU'><span id='SfqiU'><b id='SfqiU'><form id='SfqiU'><ins id='SfqiU'></ins><ul id='SfqiU'></ul><sub id='SfqiU'></sub></form><legend id='SfqiU'></legend><bdo id='SfqiU'><pre id='SfqiU'><center id='SfqiU'></center></pre></bdo></b><th id='SfqiU'></th></span></q></dt></tr></i><div id='SfqiU'><tfoot id='SfqiU'></tfoot><dl id='SfqiU'><fieldset id='SfqiU'></fieldset></dl></div>

              • <small id='SfqiU'></small><noframes id='SfqiU'>

              • <tfoot id='SfqiU'></tfoot>
                  <bdo id='SfqiU'></bdo><ul id='SfqiU'></ul>
                  本文介绍了gulp:如何在不刷新的情况下更新浏览器(仅适用于 css 更改)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我已设置 gulp,以便在我进行更改时重新加载浏览器.但是,对于 css 更改,我希望浏览器在不刷新的情况下更新,但我不确定如何执行此操作.对于我当前的设置,我使用了 this 教程:

                  I've setup gulp such that the browser reloads when I make changes. However, for css changes I want the browser to update without refresh, but I'm not sure how to do this. For my current setup I've used this tutorial:

                  var debug = require('gulp-debug'),
                      connect = require('gulp-connect'),
                      watch = require('gulp-watch'),
                      livereload = require('gulp-livereload');
                  
                  gulp.task('webserver', function () {
                      connect.server({
                          livereload: true,
                          root: ['demo/']
                      });
                  });
                  
                  gulp.task('livereload', function () {
                      gulp.src(['index.html', 'resources/**/*.js'])
                          .pipe(watch(['resources/**/*.html', 'index.html']))
                          //.pipe(debug({verbose: true}))
                          .pipe(connect.reload());
                  });
                  
                  gulp.task('watch', function () {
                      livereload.listen();
                      gulp.watch('resources/**/*.scss', ['css']);
                  });
                  

                  在我的 css 任务中,我也调用了

                  In my css task I also call

                  .pipe(livereload());
                  

                  有什么建议我需要修改以便 css 更新无需刷新即可发生吗?

                  Any suggestions what I need to modify so css updates happen without a refresh ?

                  更新:这是我的 css 任务(有点简化):

                  UPDATE: Here is my css task (a bit simplified):

                  gulp.task('css', function () {
                      ...
                      return gulp.src('demo.scss')
                          .pipe($.sass({
                              errLogToConsole: true
                          }))
                          .pipe(gulp.dest('./target/')
                          .pipe(livereload());
                  });
                  

                  推荐答案

                  发生变化时需要调用livereload.changed(files).为此,请参阅 gulp-watch文档.

                  You need to call livereload.changed(files) when change happens. To do that see gulp-watch doc.

                  watch('**/*.js', function (files) {
                    livereload.changed(files)
                  });
                  

                  这篇关于gulp:如何在不刷新的情况下更新浏览器(仅适用于 css 更改)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:使用循环运行 Gulp 任务 下一篇:这段将多个js文件合二为一的代码有什么问题?

                  相关文章

                  最新文章

                  <small id='gbeVg'></small><noframes id='gbeVg'>

                    <legend id='gbeVg'><style id='gbeVg'><dir id='gbeVg'><q id='gbeVg'></q></dir></style></legend>
                  1. <i id='gbeVg'><tr id='gbeVg'><dt id='gbeVg'><q id='gbeVg'><span id='gbeVg'><b id='gbeVg'><form id='gbeVg'><ins id='gbeVg'></ins><ul id='gbeVg'></ul><sub id='gbeVg'></sub></form><legend id='gbeVg'></legend><bdo id='gbeVg'><pre id='gbeVg'><center id='gbeVg'></center></pre></bdo></b><th id='gbeVg'></th></span></q></dt></tr></i><div id='gbeVg'><tfoot id='gbeVg'></tfoot><dl id='gbeVg'><fieldset id='gbeVg'></fieldset></dl></div>
                      <tfoot id='gbeVg'></tfoot>

                      • <bdo id='gbeVg'></bdo><ul id='gbeVg'></ul>