Tag: gruntjs

如何通过grunt-contrib-uglify来整理js文件?

我有一个如下所示的目录: /folder/b.js /folder/jQuery.js /folder/a.js /folder/sub/c.js 我想要将所有这些js文件按顺序放在一个js文件中 : jQuery.js – > a.js – > b.js – > c.js 问: 1.如何通过grunt-contrib-uglify来做到这一点(事实上,有很多文件,单独指定所有源文件path是不切实际的) 2.btw,如何在debugging的时候得到unminified文件,释放的时候得到缩小的单个文件,而不需要改变html中的脚本标签 (以及如何编写脚本标签)?

Yeoman for Angular,那么“grunt serve”就不会启动

这是我第一次使用yeoman来设置AngularJS应用程序的脚手架,我不得不承认,我很可能是nodeJS,grunt和bower世界的新手。 所以,这是我迄今为止所做的: 我确定yeoman,grunt-cli和angular发生器包被安装 npm install -g yo grunt-cli bower npm install -g generator-angular 生成我的应用程序 yo angular 我也试过: yo angular –min-safe 到目前为止,al看起来不错。 在给出的选项之间,我select了Twitter Bootstrap之一,没有angular度依赖关系,并覆盖我的本地.gitignore文件。 毕竟,我尝试运行我的应用程序: grunt serve 在这一点上,grunt抱怨说它没有在本地安装到项目中,所以我运行: npm install grunt –save-dev 再次尝试运行该应用程序: grunt serve 这是我被阻止的地方: C:\Projects\what-now>grunt serve Running "serve" task Running "clean:server" (clean) task Running "concurrent:server" (concurrent) task Running "copy:styles" (copy) task Done, without errors. […]

grunt“test command”在npm init上做了什么?

我正在努力学习咕噜声。 当我运行npm init时,在创build一个package.json文件的过程中,我得到一个提示,要求input“test command” – 我不知道如何利用它,或者期望什么。 这似乎没有很好的文件。 如果我把它留空,我在得到的package.json文件中得到这个: "scripts": { //"test": "echo \"Error: no test specified\" && exit 1" }, 任何人都可以阐明如何设置testing脚本?

gruntjs服务器任务的目的是什么?

我正在学习如何推动使用gruntjs。 我发现服务器的任务,但我不明白的地步。 我可以使用服务器任务映射级联/缩小文件来testing我的应用程序(使用backbone.js)而不移动或将源文件放在Web服务器根目录中? 没有Apache例如。 如果不是,那么服务器任务应该使用什么?

用grunt自动化npm和bower安装

我有一个node / angular项目,使用npm作为后端依赖pipe理,而bower作为前端依赖pipe理。 我想使用一个咕task任务来执行两个安装命令。 我一直无法弄清楚如何去做。 我试图使用exec ,但实际上并没有安装任何东西。 module.exports = function(grunt) { grunt.registerTask('install', 'install the backend and frontend dependencies', function() { // adapted from http://www.dzone.com/snippets/execute-unix-command-nodejs var exec = require('child_process').exec, sys = require('sys'); function puts(error, stdout, stderr) { console.log(stdout); sys.puts(stdout) } // assuming this command is run from the root of the repo exec('bower install', {cwd: './frontend'}, […]

如何判断npm包是全局还是本地安装的

我正在windows7上安装grunt,node,npm,bower和grunt-cli。 说明说我应该运行带有-g标志的全局安装命令。 如何检查我安装时是否使用了-g标志。 卸载并重新安装需要很长时间。

运行“grunt”命令时出现“致命错误:无法find本地grunt”

我用下面的命令卸载了grunt。 npm uninstall -g grunt 然后我再次用下面的命令安装了grunt。 npm install -g grunt-cli 请访问以下链接: https : //npmjs.org/package/grunt-html 我想使用上面的咕噜插件 但是当我运行grunt命令时,它给了我下面的错误: D:\nodeJS\node_modules\grunt-html>grunt grunt-cli: The grunt command line interface. (v0.1.6) Fatal error: Unable to find local grunt. If you're seeing this message, either a Gruntfile wasn't found or grunt hasn't been installed locally to your project. For more information about installing […]

咕噜(minimatch / glob)文件夹排除

我有一个情况,我试图用grunt来删除一个代码库,不包括特定的文件夹。 咕噜使用minimatch(类似于bsdglob)在引擎盖下匹配文件,但我似乎无法弄清楚如何做一个.gitignore风格排除一个文件夹。 我想要摄取这个: ignoreme 并匹配这些: /folder/path/here/to/something/ok.js /another/folder/path.js /test.js 但不匹配这些: /folder/ignoreme/something.js /folder/path/here/to/ignoreme/metoo/file.js 这将匹配一切,包括忽略: /**/*.js 所以我想我可以做一些事情: /**/!(ignoreme)/**/*.js 但是匹配ignoreme文件夹中的文件。 我习惯了正则expression式,但似乎无法弄清楚如何在这里重复模式或东西 – 我也尝试过这样的东西: /(!(ignoreme)|*)*/*.js 希望容器可以重复,但是这不起作用,它只是没有匹配所有的东西。 任何方式来传递一个正则expression式grunt文件path,或使这对我工作? 更新: 以下是我目前正在处理的问题: var pattern = /\/ignoreme\// var files = grunt.file.expandFiles(arrayOfFilesPassedToMinimatch).filter(function(f){ return !pattern.test(f) }) 我仍然有兴趣,如果文件夹排除可能在minimatch。

用nodejsreplace文件中的string

我使用md5 grunt任务来生成MD5文件名。 现在我想用任务callback中的新文件名来重命名html文件中的源文件。 我想知道最简单的方法是什么。