草庐IT

grunt-ngdocs

全部标签

node.js - Grunt : execute node process and watch 中的类似 Nodemon 的任务

我觉得我错过了什么。这是我想要实现的目标:有一个执行我的server.js并并行运行watch任务的grunt任务。在我看来,这正是grunt设计的任务之一,但我无法实现这种配置。除其他外,我读过这个:RunningNodeappthroughGrunt但我还是做不到。这是我的Gruntfile.js:module.exports=function(grunt){//Projectconfiguration.grunt.initConfig({watch:{scripts:{files:['*.js'],tasks:['start'],options:{nospawn:true}}}}

node.js - Grunt 中的 NodeJS 环境变量

我正在将我的项目从简单的nodeserver.js转变为使用Grunt。我以前直接从webstorm运行我的应用程序,并且会为我设置环境变量。我怎样才能在Grunt中达到同样的效果?我需要从webstorm(windows)运行grunt,或者在运行grunt(显式)时设置环境变量部署时这不是问题,因为heroku已经负责设置我的环境变量。 最佳答案 使用grunt-env插件:https://npmjs.org/package/grunt-env并设置您的配置:grunt.initConfig({env:{options:{//S

javascript - 使用 grunt 将版本号动态添加到 dest 输出文件

我有一个package.json文件,里面有我们的版本号,比如:{name:"myproject"version:"2.0"}我的目标是将package.json文件中的版本号动态添加到输出文件中。例如,在javascript中,我不想手动更新版本号,但希望在每次grunt构建后生成类似于此的内容:/*MyProject,v2.0*/window.myProject={version:"2.0"};在我的Gruntfile.js配置中是否有一种简单的方法可以做到这一点? 最佳答案 我实现了:https://github.com/er

node.js - npm peerDependency 问题与 grunt 和 flatiron peer

在发布这个问题时,我想出了答案,但我会在这里发布,以防它帮助其他人,也许有人可以帮助解决发生的原因。当我运行时:sudonpminstall-ggrunt它的最后一部分说:/usr/bin/grunt->/usr/lib/node_modules/grunt/bin/gruntnpmERR!peerinvalidThepackageflatirondoesnotsatisfyitssiblings'peerDependenciesrequirements!npmERR!peerinvalidPeerflatiron-cli-config@0.1.3wantsflatiron@~0.1.

javascript - 用于开发/生产环境的备用 grunt.js 任务

我正在尝试设置我的grunt.js文件,以便它仅在我的生产服务器上运行时运行min任务-在我的本地开发服务器上运行时我不想min我的代码每次更改都是不必要的。关于grunt.js如何区分开发/生产环境有什么想法吗? 最佳答案 注册生产任务://onthedevserver,onlyconcatgrunt.registerTask('default',['concat']);//onproduction,concatandminifygrunt.registerTask('prod',['concat','min']);在您的开发服务

node.js - Yeoman for Angular,然后 "grunt serve"将无法启动

这是我第一次使用yeoman为AngularJS应用程序设置脚手架,我不得不承认我可能是nodeJS、grunt和bower世界的新手。所以,这是我到目前为止所做的:我确保安装了yeoman、grunt-cli和angular-generator软件包npminstall-gyogrunt-clibowernpminstall-ggenerator-angular生成了我的应用yoangular我也试过了:yoangular--min-safe到目前为止,al似乎还不错。在给定的选项之间,我选择TwitterBootstrap之一,没有Angular依赖,并覆盖我的本地.gitigno

javascript - 如何通过 grunt-contrib-uglify 按顺序缩小 js 文件?

我有一个如下目录:/文件夹/b.js/文件夹/jQuery.js/文件夹/a.js/文件夹/sub/c.js我想按顺序将所有这些js文件压缩到一个js文件中:jQuery.js->a.js->b.js->c.js问:1.如何通过grunt-contrib-uglify实现?(其实文件很多,单独指定所有源文件路径是不切实际的)2.btw,如何在调试时获取未缩小的文件,在发布时获取缩小的单个文件,并且无需更改html中的script标签(以及如何编写脚本标签)? 最佳答案 好问题!1)Uglify将重新排序目标文件中的函数,以便函数定义

node.js - Grunt : Watch multiple files, 仅编译已更改

我是Grunt的新手,到目前为止我非常喜欢它。我希望Grunt在运行gruntwatch时只编译更改的文件在我的Grunfile.coffee我目前有(相关部分)。注意:assets/javascript/app.coffee和assets/javascript/app.js是目录coffee:default:expand:truecwd:"assets/javascript/app.coffee"src:["*.coffee"]dest:"assets/javascript/app.js"ext:".js"uglify:dev:options:beautify:truecompres

node.js - 在 Travis CI 上运行 grunt build 命令

我正在使用TravisCI测试和构建我的项目,作为其中的一部分,我希望travis运行gruntbuild我尝试了以下方法但没有运气。脚本:“gruntbuild”脚本:“./node_modules/gruntbuild”脚本:“./node_modules/grunt/gruntbuild”脚本:“./node_modules/grunt/grunt.jsbuild” 最佳答案 您是否确保在TravisNode上全局安装grunt-cli?我的TravisCI配置如下:language:node_jsnode_js:-"0.8"

node.js - 咕噜声错误 : cannot find module 'load-grunt-tasks'

当我使用grunt命令时,它显示以下错误:$gruntLoading"Gruntfile.js"tasks...ERROR>>Error:Cannotfindmodule'load-grunt-tasks'Warning:Task"default"notfound.Use--forcetocontinue.Abortedduetowarnings.ExecutionTime(2015-02-0718:05:42UTC)loadingtasks339ms███████████████████████████████████████████████99%Total344ms我已经尝试过-n