草庐IT

grunt-exec

全部标签

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 - 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 - 使用 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

javascript - 使用 Grunt 迭代模板

我正在构建一个grunt文件,我有2个文件夹需要应用相同的grunt任务。我希望能够使用grunttemplate属性遍历每个文件夹,这样我就不必通过重复配置对象来膨胀我的grunt配置对象。像这样:app1:{name:'app1',src:['src/app/'],jsTpl:['//templates/**/*.js'],js:'/**/*.js'},app2{name:'app2',src:['src/app/'],jsTpl:['//templates/**/*.js'],js:'/**/*.js'},concat:{app1:{src:[''],dest:['dist']}

javascript - 创建用于处理文件的自定义 grunt 任务

我正在尝试编写一个grunt任务,它将遍历一组输入文件并对每个文件运行转换。假设输入文件由*.in给出,任务将为每个文件创建一个.out文件。根据我的阅读,配置似乎应该是这样的grunt.initConfig({my_task:{src:'C:/temp/*.in',dest:'C:/temp/output/*.out'}});任务注册应该是:grunt.registerTask('my_task','iteratefiles',function(){//iteratefiles.});我不知道如何让grunt向我发送文件列表并遍历它们。知道怎么做吗? 最佳

javascript - Angularjs 缩小使用 grunt uglify 导致 js 错误

在angularjs中,我们将参数作为依赖注入(inject)传递。例如,functioncheckInCtrl($scope,$rootScope,$location,$http){…..….}所以当它被缩小时,它就变成了,functioncheckInCtrl(a,b,c,d){}现在a,b,c,d不会被Angular分别解释为$scope,$rootScope,$location,$http并且整个代码无法工作。为此angularjs提供了一种解决方案,就是checkInCtrl.$inject=['$scope','$rootScope',$location','$http']