简体   繁体   English

如何优化gulp-jade任务

[英]How optimize gulp-jade task

I have task for compile jade to html 我有将翡翠编译为html的任务

gulp.task('jade', function() {
var j = jade({});
j.on('error', function(e){
  gutil.log(e);
  j.end();
});
return gulp.src([
  'src/templates/**/*.jade',
  '!src/templates/mixins/**/*.jade',
  '!src/templates/index.jade'
])
.pipe(j)
.pipe(gulp.dest(outputDir+'/templates'))
.pipe(connect.reload());
});

Compiling has 3 seconds after every change+save. 每次更改+保存后,编译将持续3秒钟。 How I can improve this process? 我如何改善这个过程?

PS I use gulp-jade plugin. PS我使用gulp-jade插件。

Option 1 选项1

Use gulp-watch 使用手表

File watcher that uses super-fast chokidar and emits vinyl objects. 使用超快chokidar并发出乙烯基对象的文件监视程序。

gulp-watch will monitor a glob for changes (returned through file system events from chokidar ) gulp-watch将监视全局变化(通过chokidar的文件系统事件返回

A project I work on watches around 20k files, which get compiled pretty much instantly. 我从事的一个项目监视着约2万个文件,这些文件几乎立即被编译。

Option 2 选项2

You can skip all config and run harp + browsersync easily. 您可以跳过所有配置并轻松运行Harp + browsersync。 If your project doesn't do much more than compile from src to dest 1-on-1, you can set it up under a minute or so. 如果您的项目除了从srcdest 1-on-1编译外所做的工作不多,您可以在一分钟左右的时间内完成设置。 There is a gist of this to get started in no time (disclaimer: I am the author of the gist) . 马上就有一个要点 (免责声明:我是要点的作者)

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

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