草庐IT

grunt-contrib-watch

全部标签

javascript - 使用 grunt 连接所有 vendor 的 javascript 文件?

我使用Yeoman(v1.x)和grunt(v0.4.2)构建Angular项目。build任务连接了我所有的app/scriptJS文件,但它没有连接我所有的依赖文件,因此我构建的index.html进行了这些调用:我希望我的项目使用的所有组件,即angular.js、jquery.js等等,都在scripts.js中。重新配置GruntFile是否容易?还是出于实际原因默认情况下不这样做? 最佳答案 是的,这很容易配置。只需在传递gruntconcat任务的源代码中添加vendor脚本。//Projectconfiguratio

javascript - 在 initConfig() 中访问 Grunt 配置数据

如何访问Grunt配置属性site以读取配置属性值指定路径中的project.json文件?grunt.registerTask('build',function(target){grunt.config('site',target);grunt.task.run('foo:dist','bar:dist');});grunt.initConfig({pkg:grunt.file.readJSON('package.json'),site:grunt.file.readJSON('./sites/'+grunt.config('site')+'/project.json')});gru

javascript - 如何将 package.json 数组传递给 grunt.js

有没有办法从package.json文件中将数组传递给grunt.js?我尝试了几种不同的方法,但似乎都不起作用。我目前有:/*globalmodule:false*/module.exports=function(grunt){//Projectconfiguration.grunt.initConfig({pkg:'',lint:{files:''}//Defaulttask'lintqunitconcatmin'grunt.registerTask('default','lint');};包.json{"lint":["grunt.js","test.js"]}我能找到的唯一解决

javascript - 'grunt' 命令不执行任何操作

我正在关注gruntgettingstartedguide对于我的新应用程序,但我遇到了一些麻烦。这是我的Gruntfile.jsmodule.exports=function(grunt){//Projectconfiguration.grunt.initConfig({pkg:grunt.file.readJSON('package.json'),uglify:{,build:{src:'js/*.js',dest:'build/*.min.js'}}});//Loadthepluginthatprovidesthe"uglify"task.grunt.loadNpmTasks('

javascript - 纠错后 Grunt watch 运行得更少

我遇到了GruntWatch目前在编译错误更正后没有重新运行任务的问题。我收到错误消息,但在更正错误后,grunt说文件已更改,但在那之后没有任务运行。咕噜声文件:watch:{less:{files:['public/assets/less/**/*.less'],tasks:['css'],options:{atBegin:true,nospawn:true}},scripts:{files:['public/assets/js/homepage.js'],tasks:['jsApp'],options:{nospawn:true,}}},错误日志:>>ParseError:Unr

javascript - $watch 与 ngChange

假设您想要在$scope的属性更改时执行某些操作。并说此属性绑定(bind)到input字段。使用$watch与使用ngChange有哪些优点/缺点?htmlfoo:{{foo}}fooChangeCount:{{fooChangeCount}}js//Option1:$watch$scope.$watch('foo',function(){$scope.fooChangeCount++;});//Option2:ngChange$scope.fooChangeCount=0;$scope.increment=function(){$scope.fooChangeCount++;};h

javascript - grunt-contrib-watch with LiveReload 不工作

我无法让LiveReload与Grunt一起工作。我正在使用grunt-contrib-watch。当Grunt查看指定的文件时,浏览器中没有重新加载任何内容。所以我会看到:Running"watch"taskCompletedin0.203satThuNov21201300:59:59GMT-0500(EST)-Waiting...OK>>File"views/index.html"changed.但是浏览器窗口没有更新。我正在使用LiveReload2.0.9。关于如何让它运行有什么建议吗?Gruntfile.jsmodule.exports=function(grunt){'us

javascript - Grunt-eslint 并启用 `--fix` 标志以自动修复违规

我知道eslintCLI本身有一个--fix标志,但我无法从文档中得知如何通过eslintConfig使用它>(在package.json中)或在我的Gruntfile中的grunt-eslint配置中。我在package.json中有以下配置:"env":{"browser":true,"amd":true},"extends":"eslint:recommended",并使用此Grunt配置通过lint任务调用它:eslint:{target:['src/app/**/*.js'],format:'checkstyle'},如何在这种情况下启用--fix标志?

javascript - 在没有 $scope 的情况下使用 $watch( Controller 作为语法)

在Angular1.3中,可以使用this.foo='bar'代替$scope.foo='bar'。现在,如何在没有$scope的情况下使用$watch? 最佳答案 在使用controlleras语法时,有几个选项可以避免必须使用$watch。以下示例摘自blogpostIwroteaboutavoiding$scope.使用ng-changeIfyouhaveawatchsetuptolistenforapropertychangethatoriginatesfromaformfield,thenng-changeisyourbe

javascript - 使用 grunt-contrib-watch 深度单向同步两个目录。代码有效,但 grunt-contrib-watch 重新初始化时间太慢

我有两个目录src和compiled。我想使用GruntWatch确保从src到compiled的单向数据同步.作为中间步骤,我想编译*.less文件以及使用ES6语法编写的*.js文件的子集。我已经成功编写了满足我需要的任务://NOTE:Spawnmustbedisabledtokeepwatchrunningundersamecontextinordertodynamicallymodifyconfigfile.watch:{//CompileLESSfilesto'compiled'directory.less:{options:{interrupt:true,spawn:fa