Gulp Concat + Browserync重启


陆离
2025-02-24 09:40:04 (58分钟前)
  1. 我正在使用



</跨度>
concat和browserync。我跑的时候


</跨度>
,它启动browserync并连接并重新加载模块中找到的所有js文件。问题是它只进行了一次js文件的连接,所以我需要停止运行


</跨度>
并再次运行它,以便我可以看到任何反映到js文件的变化。我只看到了


</跨度>
停止并重新启动后通知任务


</跨度>
太。我该如何设置


</跨度>
这样的

3 条回复
  1. 0# 是吗@ | 2019-08-31 10-32



    我不确定,但你可以试试




    gulp.watch(‘app/modules/*/.js’, [‘scripts’]);



    在任务“默认”下



    据我所知,你的gulp没有看你的文件并运行脚本



    附:如果不能解决的话,我不是专家,我很抱歉。


  2. 1# v-star*위위 | 2019-08-31 10-32



    试试这个:




    1. // watch
      gulp.task(‘watch’, [‘browserSync’, scripts’], function (){
      // Reloads the browser whenever HTML or JS files change
      gulp.watch(‘app/.html’, browserSync.reload);
      gulp.watch(‘app/modules/**/
      .js’, [‘scripts’]);
      });

    2. gulp.task(‘scripts’, function() {
      return gulp.src(‘app/modules//.js’)
      .pipe(concat(‘main.js’))
      .pipe(gulp.dest(‘app/build/js’))
      .pipe(notify({ message: Scripts in modules have been bundled!’ }))
      .pipe(browserSync.reload({
      stream: true
      }));
      });

    3. gulp.task(‘default’, [‘watch’, scripts’]);

    4. </code>

登录 后才能参与评论