Tag: gruntjs

用grunt运行2个asynchronous任务

我正在一个小型的节点项目上工作,我使用coffeescript和更less的客户端代码。 我正在尝试使用grunt设置我的开发环境。 我已经实现了像这样运行服务器的自定义grunt任务: start = require './start' #just a function to start express.js application grunt.registerTask 'server', 'Starting server', -> grunt.log.write 'Preparing server to start' done = do @async start (err) -> grunt.log.write "server running at localhost:4000" 我也想用grunt-contrib-watch插件运行“watch”任务: grunt.initConfig watch: coffee: files: ['public/coffee/**/*.coffee'] tasks: ['coffee'] jade: files: ['public/jade/**/*.jade'] tasks: ['jade'] less: files: ['public/less/**/*.less'] tasks: ['less'] 问题是:如何使这两个任务(手表和服务器)同时运行? […]

节点js作为http服务器和主机angularJS SPA

我有一个应用程序写在angularJS和grunt构build。 有没有一种方法可以从节点js创build一个http服务器并将其托pipe在那里。 请分享任何代码片段或文件,这将有所帮助。 谢谢

如何使用我自己的选项configurationconcat和uglify与grunt-usemin

例如:我使用下面的当前configurationuglify我的Gruntfile中的JS脚本: uglify: { options: { report: "min", //"gzip", sourceMap: true, preserveComments: false, //"some", "all" }, application: { options: { // expand: true, banner: '<%= app.banner %>', preserveComments: "some" }, src: 'dist/js/application.js', dest: ".tmp/js/application.min.js" }, dependencies: { options: { sourceMap: false }, src: ['dist/js/dependencies.js'], dest: ".tmp/js/dependencies.min.js" }, 我知道,grunt-usemin从useminPrepare gruntfile选项中声明的html文件中的代码块生成src和dest选项,例如: <!– build:js js/app.js –> <script src="js/app.js"></script> <script […]

grunt.js – 缩小文件时的多个目的地

我的grunt.js有一个典型的缩小任务: min: { dist: { src: ['dist/precook.js'], dest: 'dist/precook.min.js' } } 有多个dest文件最简单的方法是什么? 我想简化成: DIST / precook.min.js 例如/ JS /供应商/ precook.min.js 内置的最小任务似乎不支持多个目的地,所以我认为这可以通过一个简单的“复制”任务来实现。 有人能指点我的方向吗?

是什么导致/ *全局模块:false * / in grunt.js

许多grunt.js脚本开始于: /*global module:false*/ module.exports = function(grunt) { 但是,第一行中的评论的原因是什么?

Ember.js如何引用Grunt.js预编译的Handlebars模板?

我一直在探索Ember.js,以及Grunt.js,但我不明白Ember.js如何能够find并使用预编译的Handlebars模板。 现在我的Gruntfile.js看起来像这样: module.exports = function(grunt) { // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), handlebars: { compile: { files: { "js/templates.js": "templates/*.hbs", } } } }); // Load the plugin that handles the handlebars compiling grunt.loadNpmTasks('grunt-contrib-handlebars'); // Default task(s). grunt.registerTask('default', ['handlebars']); }; 我的app.js Ember视图是这样声明的(路由和控制器被省略): App.LogoView = Ember.View.extend({ templateName: 'logo', classNames: ['logo'] }); App.TabsView = Ember.View.extend({ templateName: 'tabs', […]

为什么npm init实际上初始化一个咕噜项目?

我非常难以理解Node生态系统,以及npm和它的包如何协同工作,我发现npm init初始化一个“grunt项目”,并在你的目录中添加一个package.json文件是很奇怪的。 由于节点包pipe理器pipe理许多不同的“包”,我期望更像npm grunt init东西 任何人都可以填写我在这里发生了什么,什么使得咕噜声如此特别以至于成为主要的npm init命令? ** 重要提示 **在学习和理解了所有这些之后,我强烈build议您不要使用Grunt NOR Gulp,而是将中间人拿出来,并使用npm脚本来满足您的前端构build需求。 请参阅Cory House的这篇文章,了解更多信息

咕噜和凉亭heroku上

今天我想将我的node.js应用程序部署到heroku。 当地我正在使用bower和grunt发展也我想仍然使用它们。 现在,按照我在networking上发现的一些build议,我将bower添加到了我的dependencies并添加了"postinstall": "node_modules/.bin/bower install到我的package.json postinstall 。 现在我有一些grunt问题。 当我把我的grunt依赖从devDependencies移到dependencies , grunt不能识别我的tasks ,例如当我有 { "name": "js-linkedin-connector", "version": "0.1.0", "dependencies": { "passport": "~0.1.17", "passport-local": "~0.1.6", "passport-linkedin-oauth2": "~1.0.1", "connect": "~2.11.0", "underscore": "~1.5.2", "bower": "1.2.x", "grunt": "~0.4.1", "grunt-cli": "0.1.11", "load-grunt-tasks": "~0.1.0", "grunt-contrib-copy": "~0.4.1", "grunt-contrib-concat": "~0.3.0", "grunt-contrib-coffee": "~0.7.0", "grunt-contrib-uglify": "~0.2.0", "grunt-contrib-compass": "~0.5.0", "grunt-contrib-jshint": "~0.6.0", "grunt-contrib-cssmin": "~0.6.0", "grunt-contrib-connect": "~0.5.0", "grunt-contrib-clean": "~0.5.0", […]

我正在与Yeoman进行克隆回购,我的电脑上需要什么configuration?

我已经克隆了已安装Yeoman的回购。 我安装了Node,还有Yeoman npm i -g yo 。 当我跑grunt我得到一个错误,指出: Error: Cannot find module 'load-grunt-tasks' Warning: Task "default" not found. Use –force to continue. 我还需要做什么才能成功运行这个回购协议?

grunt.js的全局安装失败

我可以使用npm install grunt在本地安装gruntjs 。 但是,当我试图全局npm install grunt -g ,我得到一个错误: npm ERR! Error: EACCES, symlink '../lib/node_modules/grunt/bin/grunt' npm ERR! npm ERR! Please try running this command again as root/Administrator. npm ERR! npm ERR! System Linux 2.6.18-92.el5xen npm ERR! command "nodejs" "/usr/bin/npm" "install" "grunt" "-g" npm ERR! cwd /home/lj npm ERR! node -v v0.6.18 npm ERR! npm -v […]