Tag: gruntjs

Grunt中的NodeJS环境variables

我将我的项目从简单的node server.js转移到使用Grunt。 我曾经直接从webstorm运行我的应用程序,并为我设置了环境variables。 我怎样才能在Grunt中实现相同? 我需要从webstorm(windows)运行grunt,或者在运行grunt(显式)时设置env vars, 这在部署时不是问题,因为heroku已经负责设置我的环境variables。

Grunt usemin和usemin准备多个目标

从usemin问题看来,usemin和useminPrepare支持最新版本中的多个目标: useminPrepare支持: https://github.com/yeoman/grunt-usemin/pull/162 https://github.com/yeoman/grunt-usemin/pull/206 usemin支持: https://github.com/yeoman/grunt-usemin/issues/57 我试过用以下configuration使用多个目标: useminPrepare: { foo: { dest: 'fooDist', src: ['foo/index.html'] }, bar: { dest: 'barDist', src: ['bar/index.html'] } }, usemin: { foo: { options: { assetsDirs : ['fooDist'] }, html: ['fooDist/**/*.html'], css: ['fooDist/styles/**/*.css'] }, bar: { options: { assetsDirs : ['barDist'] }, html: ['barDist/**/*.html'], css: ['barDist/styles/**/*.css'] } }, 但我收到以下错误: 运行“usemin:foo”(usemin)任务警告:不支持的模式:foo […]

Grunt中的Nodemon-like任务:执行节点进程和监视

我觉得我失去了一些东西。 这是我想要达到的: 有一个咕噜的任务执行我的server.js和并行运行watch任务。 我觉得这正是Gruntdevise的任务之一,但我无法实现这种configuration。 其中,我读过这个: 通过Grunt运行Node应用程序,但我仍然无法做到。 这是我的Gruntfile.js: module.exports = function(grunt) { // Project configuration. grunt.initConfig({ watch: { scripts: { files: ['*.js'], tasks: ['start'], options: { nospawn: true } } } }); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.registerTask('start', function() { grunt.util.spawn({ cmd: 'node', args: ['server.js'] }); grunt.task.run('watch'); }); grunt.registerTask('default', 'start'); }; 我有"grunt-contrib-watch": "~0.3.1" grunt-contrib-watch@0.3.0 "grunt-contrib-watch": "~0.3.1" ,应该比前面提到的文章更高版本,比grunt-contrib-watch@0.3.0 。 如果你能帮我实现适当的configuration,我将非常感激。 但更一般的说,我不明白为什么没有官方的grunt-contrib-nodemon-like软件包和任务,因为我感觉这将是使用grunt(我真的很喜欢这个工具! […]

如何使Grunt Deploy使用全局NPM模块而不是本地模块

首先,我对npm和grunt很新。 我们有一个项目,我们正在使用Grunt来编译和生成输出文件。 我试图设置我们的生成服务器使用Grunt生成输出文件。 我们正在使用Windows与TFS源代码控制,并由于它的260个字符的path限制 ,我们无法检查到源代码pipe理( 因为它单独使用230个字符安装path )的grunt-bower-task模块。 当我从我的项目目录运行npm install时 ,它工作正常,并将以下必需模块安装到我的项目目录中的node_modules文件夹中: 咕噜 咕噜鲍尔任务 咕噜-的contrib罗盘 咕噜-的contrib-CONNECT 咕噜-的contrib-jshint 咕噜-的contrib-requirejs 咕噜-的contrib手表 然后当我从我的项目目录运行grunt部署一切都按预期工作。 虽然我可以简单地使运行npm install构build过程的一部分,但我不愿意,因为它需要几分钟时间才能下载所有文件,而且我不希望我们的构build依赖于可用的外部Web服务。 我已经看到, 您可以在本地或全局安装模块 ,所以我希望能够在生成服务器上全局安装模块,以便它们不需要直接在项目目录内的node_modules文件夹中运行grunt部署 。 我已经运行了npm install -g ,以及上面列出的每个模块的npm install -g [module] ,以及npm install -g grunt-cli 。 如果我做npm前缀-g,它会告诉我全局模块目录是C:\ Users [我的用户] \ AppData \ Roaming \ npm ,当我查看该目录的node_modules文件夹时,我看到所有的模块。 但是,当我运行grunt部署它抱怨: 致命错误:无法find本地咕噜声 如果我只包含* node_modules \ grunt *目录,那么我仍然得到这些错误: 没有find本地Npm模块“grunt-contrib-watch”。 是否安装? […]

Grunt需要在系统PATH警告中安装指南针

我想安装Yeoman,Grunt和凉亭到我的节点项目。 我在Eclipse中创build了一个节点项目(使用nodeclipse插件),并在cmd中导航到项目文件夹(H:\ Eclipse Workspace \ YoTest),并input: npm install yo -g npm install generator-webapp -g yo webapp select:Sass(带指南针),以cmd为单位 然后键入: grunt serve 运行webapp。 我收到以下错误信息: Done, without errors. Warning: Running "compass:server" (compass) task Warnin: You need to have Ruby and Compass installed and in your system PATH for this task to work. More info: https://github.com/gruntjs/grunt-contrib-compass Use –force to […]

如何从不同于我的根项目的文件夹运行grunt

有没有办法告诉咕噜哪个grunt.js文件使用? 我有一个f:\a\b\tools文件夹,其中包含grunt.cmd, node.exe,… ,我的实际web应用程序与GruntFile.js和所有本地node_modules是在f:\a\c\my_app 从a\c\my_app运行grunt工作正常,但试图从其他文件夹运行grunt说,似乎并没有工作。 我是新来的咕噜,可能是我失去了一些明显的东西。 f:\a>grunt –config c\GruntFile.js grunt-cli:咕噜的命令行界面。 (v0.1.6) 致命错误:无法find本地咕噜声。 如果你看到这个消息,Gruntfile找不到,或者Grunt没有在本地安装到你的项目中。 有关安装和configurationgrunt的更多信息,请参阅“入门指南”: http://gruntjs.com/getting-started

npm peer与grunt和flatiron peer的依赖问题

在发布这个问题的时候,我想出了答案,但是我会在这里发帖以防别人帮忙,也许有人可以帮忙解释发生了什么事情。 当我运行: sudo npm install -g grunt 它的最后部分说: /usr/bin/grunt -> /usr/lib/node_modules/grunt/bin/grunt npm ERR! peerinvalid The package flatiron does not satisfy its siblings' peerDependencies requirements! npm ERR! peerinvalid Peer flatiron-cli-config@0.1.3 wants flatiron@~0.1.9 npm ERR! peerinvalid Peer flatiron-cli-users@0.1.1 wants flatiron@~0.1.9 npm ERR! System Linux 3.5.0-23-generic npm ERR! command "nodejs" "/usr/bin/npm" "install" "-g" "grunt" npm ERR! cwd /home/explunit […]

替代dev / prod环境的grunt.js任务

我正在尝试设置我的grunt.js文件,以便在我的生产服务器上运行时只运行min任务 – 在本地开发服务器上运行时,我不希望在每次更改时都删除我的代码,因为这是不必要的。 关于如何grunt.js可以区分开发/产品环境的任何想法?

警告:运行“指南针:服务器”(指南针)任务

D:\Projects\mallspk>grunt serve Running "serve" task Running "clean:server" (clean) task >> 0 paths cleaned. Running "wiredep:app" (wiredep) task Running "wiredep:test" (wiredep) task Running "wiredep:sass" (wiredep) task Running "concurrent:server" (concurrent) task Warning: Running "compass:server" (compass) task Warning: Command failed: 'compass.bat' is not recognized as an internal or exter nal command, operable program or batch file. Use –force […]

除.spec.js之外的每个.js文件的节点glob模式

我正在寻找一个更好的glob模式usemin,我想find所有的.js文件,但排除.spec.js文件。 到目前为止,我有以下解决scheme。 <script src="components/**/*(.js|!(*.spec.js|*.scss))"></script> 我现在的解决scheme要求我不断添加文件扩展名来排除它们,否则会被拿起来,例如.html文件。 我试图让它只能find.js文件,并从他们排除.spec.js ,但似乎并没有工作。 另外添加!components/**/*.spec.js作为下面的另一个脚本似乎不工作。