Tag: gruntjs

Grunt:自定义任务开发的方法

我需要实现一个自定义的Grunt任务,我完全失去了开发工作stream程。 我如何开发自定义任务,并模拟在开发过程中使用npm加载它? 有没有其他方式分发自定义任务,而不是使用npm ? 我的意思是,我可以分发一个定义整个定制Grunt任务的JavaScript文件,并直接将其导入到Gruntfile.js ? 由于整个任务将处于一个非常早期的发展阶段,所以用npm来发布它的努力可能不是一个好主意。 提前致谢。

yeoman如何设置标题(.htaccess?)

运行yeoman服务器默认情况下似乎无法识别.htaccess文件。 是否有一个额外的步骤来启用.htaccess文件的读取? 以下是我已取消注释的行,重新启动后设置标题没有明显的影响: #————————————————- ——————— #跨域AJAX请求 #————————————————- ——————— #服务跨域Ajax请求,默认情况下禁用。 #enable-cors.org #code.google.com/p/html5security/wiki/CrossOriginRequestSecurity <IfModule mod_headers.c> 标题集Access-Control-Allow-Origin“*” </ IfModule>configuration 或者,也许正确的问题是如何运行yeoman服务器时设置标题? 有没有另外的select,也许在Gruntfile.js?

如何configurationGrunt的目录recursionSass编译任务

我是一个新手,学习如何configuration咖啡,玉器和sass编译任务。 我可以成功地为咖啡和玉目录configuration编译任务,但我不能sass。 我的项目的结构是波纹pipe . ├── Gruntfile.coffee ├── node_modules ├── package.json ├── sass │ └── index.sass └── www 和我的package.json是 { "name": "grunt-sass-test", "version": "0.1.0", "devDependencies": { "grunt": "~0.4.1", "grunt-contrib-sass": "~0.5.0" } } 当Gruntfile.coffee在下面时, $ grunt sass编译index.css成功: module.exports = (grunt) -> grunt.initConfig pkg: grunt.file.readJSON('package.json') sass: compile: files:[ "www/index.css": "sass/index.sass" ] 但是如下所示, >>没有find源文件“index.sass”。 显示错误 sass: compile: cwd: 'sass' […]

如何安装Grunt

我用Homebrew来安装Node.js,然后使用npm install来安装Grunt及其依赖项,但安装完成后,我无法运行Grunt: zsh: correct 'grunt' to 'grn' ÆnyaeÅ? n zsh: command not found: grunt 什么是安装Grunt的正确方法,所以我不会得到这个错误?

Mac npm与ENOENT错误

我是最近从Windows转换到Mac,目前只是试图让我的工具设置。 我首先安装节点使用自制软件,这是给我错误(相同的,我还有)。 我后来使用自制软件删除节点,并使用节点网站上的pkg进行安装。 我可以在命令行和npm中访问节点。 问题是当我尝试在本地项目上安装模块时,我得到如下所示的内容: npm install grunt-contrib Error extracting archive { [Error: ENOENT, open '/Users/davidmckeown/dev/adt-com/node_modules/grunt-contrib/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/tmp/phantomjs-1.7.0-macosx.zip'] errno: 34, code: 'ENOENT', path: '/Users/davidmckeown/dev/adt-com/node_modules/grunt-contrib/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/tmp/phantomjs-1.7.0-macosx.zip' } 在上面的另一个消息包含: npm ERR! phantomjs@0.2.6 install: `node install.js` npm ERR! `sh "-c" "node install.js"` failed with 8 npm ERR! npm ERR! Failed at the phantomjs@0.2.6 install script. npm ERR! This is most likely […]

如何将Git哈希写入(node's)package.json?

有没有办法使用git的HEAD哈希自动更新package.json( https://npmjs.org/doc/json.html )的版本号? 我想在项目的package.json文件里有类似version: 1.0.0+rev82e4b91cfe42cd86e9453b4987b9cc446566de6东西。 EVE之前的加号手动设置和散列更新每次我提交的东西。 这可能吗? 我找不到这个话题:/

咕噜表的任务似乎需要很长时间

我正在运行两个简单的任务,每个任务的运行时间都小于100ms,但是在watch命令下运行时,两个组合任务总共花费了大约8秒(每个任务的开销似乎为3.5秒)。 我正在使用它与现场重新开发,我觉得非常沮丧。 我尝试设置spawn为false但这似乎打破了它,并没有任何相关的任务运行。 这里是从sass文件更改时的示例输出。 >> File "app/styles/main.scss" changed. File "app/styles/main.css" created. Done, without errors. Elapsed time loading tasks 4ms ▇▇▇▇▇ 9% sass 1ms ▇▇ 2% sass:dist 39ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 89% Total 44ms Completed in 3.862s at Mon Nov 18 2013 17:05:57 GMT+0000 (GMT) – Waiting… OK >> File "app/styles/main.css" changed. Running "copy:styles" (copy) task Copied 1 […]

运行跨多个grunt.js文件configuration的任务

我有一个包含多个未发布模块的节点应用程序。 我的应用程序的package.json包含一些git依赖项: "module-a": "git+ssh://git@github.com:me/module-a.git", "module-b": "git+ssh://git@github.com:me/module-b.git" 每个人都有自己的gruntconfiguration。 例如在node_modules/module-a/grunt.js : module.exports = function(grunt) { grunt.initConfig({ lint: { files: ['server/**/*.js', 'test/**/*.js'] }, jshint: { options: require('./lint-ci') } }); grunt.registerTask('default', 'lint'); }; (他们也运行testing等,但我在这里保持简单) 有没有一个内置的方式来做到这一点与咕噜? 请注意,为了方便起见,我只想保留相关的grunt.js文件,只是在该依赖项中更改了某些内容。 我find的唯一解决scheme是 以编程方式构build我的主要grunt.js(例如,遍历我的package.json中的依赖项来构buildlint和testingconfiguration) 使用–config node_modules/module-a/grunt.js多次调用grunt 两者都不是理想的。 有没有更好的办法?

使用Grunt(Yeoman)的多个构build文件夹(多个客户端,多个任务,多个目标)

我正在构build一个项目,它将是一个webapp(浏览器可运行)和一个Phonegap应用程序(iOS和Android)。 尽pipe我的项目在理论上可以使用我的Yeoman生成的相同的dist文件夹,但是Grunt任务通过运行grunt build build生产就绪代码。 我想运行一些像grunt build_web , grunt build_ios和grunt build_android ,为每个平台单独构build生产代码。 或grunt build:web , grunt build:ios , grunt build:android 。 这样,我可以自定义一些加载的脚本,图像等,每个都有自己的构build指令。 那么,我是否应该通过我的Gruntfile复制粘贴所有的dist并负责任地build指令? 或者,对此有最佳做法吗? (试过这个,没有工作) Yeoman伙计,这可能吗? 这是我目前的Gruntfile.js ,以防万一。 'use strict'; var LIVERELOAD_PORT = 35729; var lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT}); var mountFolder = function (connect, dir) { return connect.static(require('path').resolve(dir)); }; // # Globbing // for performance reasons […]

在部署Grunt应用程序到heroku时,NPM不会安装模块依赖项

我使用grunt制作了一个静态单页面网站。 我现在正在尝试使用heroku buildpack将其部署到heroku,以用于节点咕噜声。 以下是我的根目录的图片: 这是我的Gruntfile,package.json和Procfile: https://gist.github.com/callumflack/8038464 https://gist.github.com/callumflack/8038483 web:node index.html 当我$ git push heroku master它到Gruntfile并失败: —–> Found Gruntfile, running grunt heroku:production task >> Local Npm module "grunt-contrib-uglify" not found. Is it installed? 上述错误继续列出所有本地NPM模块为未find。 如果我列出所有的loadNpmTasks而不是使用“load-grunt-tasks”,我会得到完全相同的错误。 当我$ heroku logs我得到: Starting process with command `node web.js` Error: Cannot find module '/app/web.js' 任何人都可以看到我哪里出了错?