我有一个gulpfile,它应该在压缩代码之前清理我的dist目录。有时,清理任务仍在运行,而代码正在缩小,导致一些文件丢失。是什么导致它这样做?我的理解是任务的依赖将在任务运行之前完成,并且一个依赖只会运行一次,即使它是多个任务的依赖。vargulp=require('gulp');vargulpLoadPlugins=require('gulp-load-plugins');varplugins=gulpLoadPlugins();vardel=require('del');gulp.task('default',['css','js','fonts']);gulp.task('c
我的配置做了它应该做的一切,但它从不刷新浏览器。一旦我手动刷新它,就会有变化。我正在连接到默认的localhost:3000。任何想法为什么会这样或如何调试它?gulpfile.js:vargulp=require('gulp');varsass=require('gulp-sass');varsourcemaps=require('gulp-sourcemaps');varbrowserSync=require('browser-sync');gulp.task('html',function(){browserSync.reload();});gulp.task('sass',fu
使用gulp.js我有三个任务(uglify、buildHTML、rmRevManifest)我想作为父构建任务的一部分运行。我的代码有效,除了它并行运行任务(即不保留顺序)。我怎样才能让任务阻塞并且在上一个完成之前不运行下一个?即现在执行顺序返回为:[11:50:17]gulp-notify:[Gulpnotification]Deleted'rev-manifest.json'.[11:50:17]gulp-notify:[Gulpnotification]Created'build/index.html'.[11:50:17]gulp-notify:[Gulpnotificati
我正在努力做到这一点,如果未指定--theme标志,它会停止gulp任务并想知道以DRY方式完成它的最佳方法。如果未指定--theme,我希望每个单独的任务都停止,如果不满足,我也希望默认任务停止。到目前为止,我已经尝试了一些没有运气的事情。谢谢,gulp.task('test',function(){if(typeof(args.theme)=='undefined'||args.theme===true){console.log(msg.noTheme);return;//endtask}//runrestoftask...});gulp.task('test-2',functio
鉴于我的gulpfile.js中的以下代码,每次我保存或更改文件时,任务都会运行两次而不是一次,这是为什么?我只希望它运行一次。vargulp=require('gulp');gulp.task('default',function(){gulp.watch('server/**/*.js',function(){console.log('ThisrunstwiceeverytimeIchange/saveajavascriptfilelocatedatserver/**/*.js');});});我对grunt和名为grunt-contrib-watch的插件也有同样的经历。
我有一个关于usemin的问题,我不确定它是否是一个错误。我的应用程序结构很简单:-root|-gulpfile.js|-app||-index.html||-about.html||-contact.html||-js||-a.js||-b.js||-c.js||-d.js||-e.js||-dist我的每个html文件中都有一个useminblock来包含所有脚本,例如:当我运行以下任务时:gulp.task('usemin'.function(){gulp.src('app/*.html').pipe(usemin({assetDir:'app/**/'})).pipe(dest
我有以下gulpfile.js:vargulp=require('gulp'),jasmine=require('gulp-jasmine');gulp.task('default',function(){returngulp.src('spec/test.js').pipe(jasmine());});spec/test.js中的代码使用全局angular变量,但是,当我运行gulptaskdefault时会抛出一个关于它未定义的错误。假设angular是在全局范围内的文件spec/lib.js中定义的。在test.jsdescribe()之前,我如何告诉jasmine()它需要首先
...设置有问题。我使用yeoman并使用创建我的项目yogup-angular设置完成后我开始单元测试gulptest但它失败了:PSP:\projects\test-logbook>gulptest[15:15:14]UsinggulpfileP:\projects\mydisk-logbook\gulpfile.js[15:15:14]Starting'scripts'...[15:15:15]allfiles14.08kB[15:15:15]Finished'scripts'after840ms[15:15:15]Starting'test'...2809201715:15:1
给定以下gulp任务,为什么我会收到以下错误?Error:taskcompletioncallbackcalledtoomanytimesfunctionmyTask(options,cb){//cbisthegulpcbvarserverInstance=http.createServer(dispatch({/*routes*/}));serverInstance.listen(options.port,function(){cb();//Stacktraceidentifiesthislineasthrowingtheerror});}functionpartial(fn){va
我尝试设置gulp-inject以将依赖项注入(inject)index.html。除了转换功能外,一切正常。我需要按以下方式替换部分文件路径:/frontend/src/-->/static/我试过这样做(从某处复制粘贴):transform:function(filePath,file,i,length){varnewPath=filePath.replace('/frontend/src','');console.log('injectscript='+newPath);return'';}执行后,控制台中没有任何内容(标准gulp输出除外),结果文件中出现未转换的文件路径。看起