草庐IT

gulp-util

全部标签

javascript - Nodemon 重启运行 gulp 任务

我的gulpfile中有以下代码gulp.task('scripts',function(){gulp.src(paths.browserify).pipe(browserify()).pipe(gulp.dest('./build/js')).pipe(refresh(server));});gulp.task('lint',function(){gulp.src(paths.js).pipe(jshint()).pipe(jshint.reporter(stylish));});gulp.task('nodemon',function(){nodemon({script:'app.

javascript - Gulp - 从 javascript 文件中删除注释

我正在寻找一种使用gulp从javascript文件中删除所有评论的方法。例如,我有以下代码:/****Comment1-Thisismyjavascriptheader*@desccommentheadertoberemoved*@paramsreq,res*/(function(){varhelloworld='HelloWorld';//Comment2-thisisvariable/*Comment3-thisistheprinting*/console.log(helloworld);})()我的预期结果是:(function(){varhelloworld='HelloWo

javascript - 使用 Gulp + Browserify 时,对象 #<Readable> 没有方法 'write'

当关注examplerecipe时来自Gulp.js存储库。我得到一个错误:[12:27:31]UsinggulpfileC:\GH\riot-tag-build\Gulpfile.js[12:27:31]Starting'browserify'..._stream_readable.js:602varwritten=dest.write(chunk);^TypeError:Object#hasnomethod'write'atwrite(_stream_readable.js:602:24)atflow(_stream_readable.js:611:7)at_stream_read

javascript - Vue-test-utils:在单个测试中多次使用 $nextTick

我正在为vuelidate编写单元测试在我的组件中进行验证。我发现$touch()方法是异步调用的,所以我需要为expect()使用$nextTick()。当我需要两个nextTick()s用于两个expect()s时,问题就出现了。describe('Validations',()=>{letdataletmyComponentbeforeEach(()=>{data=()=>{propertyABC='notallowedvalue'}myComponent=localVue.component('dummy',{template:'',validations,data})it('

javascript - Gulp-sourcemaps 没有创建 sourcemap 文件?

我试图让Gulpsourcemaps写入文件,但我无法在任何地方看到这些文件。如果在工作树中创建了任何新文件,我会在gitstatus中看到它们,但找不到任何新文件。下面是我的gulpfile.jsvargulp=require('gulp'),sourcemaps=require('gulp-sourcemaps'),minify=require('gulp-minify'),concat=require('gulp-concat'),uglify=require('gulp-uglify');gulp.task('js',function(){returngulp.src('src

javascript - 从单独的 gulp 文件导入/读取变量

我希望将我的gulpfile.jsassets或src变量拆分到单独的文件中,以便我可以更好地管理它们。例如:....varscripts=['awful.js','lot.js','of.js','js.js','files.js']....(somewheredowntheline)gulp.task('vendorjs',function(){returngulp.src(scripts).pipe(concat('vendor.js')).pipe(rename({suffix:'.min'})).pipe(uglify()).pipe(gulp.dest(paths.root

javascript - KnockoutJS 通过 ko.utils.extend 继承功能

我正在尝试将功能从父View模型继承到subview模型,如下所示:functionParentVM(){varself=this;self.MyFunc=function(){console.log(self.SomeVar);//thislogs"undefined"}}functionChildVM(){varself=this;ko.utils.extend(self,newParentVM());self.SomeVar="hello";}但是,当MyFunc被调用时,SomeVar是未定义的。 最佳答案 如果有人为此苦苦

javascript - 通过 gulp 从 index.html 中删除脚本

我在我们的应用程序中使用gulp,我们在Gulpfile.js中有2个流程,一个用于生产,第二个用于开发,但我不想保留2个index.html文件,例如index.html和index.dev。html,我想要一个index.html文件,但是对于生产构建,我有一些不需要的脚本,例如.问题是:如何通过Gulp从html中删除某些内容? 最佳答案 您可以使用专用于此特定目的的gulp-html-replace插件:https://www.npmjs.org/package/gulp-html-replace

javascript - ko.utils.arrayFirst 在不处理非空字符串的 else block 时总是返回 null

这可以正常工作:self.getById=function(id){returnko.utils.arrayFirst(self.PostArray(),function(item){if(item.postId===id){returnitem;}else{return'notfound';}});};console.log(self.PostArray().length);console.log(self.getById(170));但如果我将return''或returnnull放在elseblock中,我总是得到null,这是为什么? 最佳答案

javascript - Gulp:如何按顺序组合任务?

我需要通过顺序处理不同的源来组合gulp任务,因为它们之间存在依赖关系。根据文档,这应该完成我的合并流,但我看不到如何强制对它们进行排序和序列化。在Gulp3中建模的正确方法是什么?我通常使用函数作为各个构建步骤的容器,然后从构建和监视任务中调用它们:functionbuildModule(module){varstreams=[];//steponestreams.push(gulp.src(path.join('./modules',module,'*.js'))//...seriesofchainedcalls);//steptwostreams.push(gulp.src([T