Tag: gruntjs

使用grunt编译less量内存问题

我目前正在使用鲍尔+咕噜build立我的网站。 bower.json依赖关系: "dependencies": { "jquery": "~2.1.3", "bootstrap": "~3.3.2", "admin-lte": "~2.0.0" }, 依赖在我的package.json : "dependencies": { "grunt": "^0.4.5", "grunt-bower-concat": "^0.4.0" }, "devDependencies": { "grunt": "^0.4.5", "grunt-contrib-concat": "^0.5.1", "grunt-contrib-copy": "^0.7.0", "grunt-contrib-cssmin": "^0.12.2", "grunt-contrib-less": "^1.0.0", "grunt-contrib-uglify": "^0.7.0", "grunt-contrib-watch": "^0.6.1", "grunt-filerev": "^2.2.0", "grunt-usemin": "^3.0.0" }, 我正在使用AdminLTE 1.4.* ,一切都很好。 我更新到AdminLTE 2.0.0 ,当我尝试编译我的less文件我收到此错误: FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed – process out […]

GruntJS / NPM package.json:从本地安装?

使用GruntJS / NPM package.json 如果我已经从github克隆了一个模块到本地,我怎么可以在我的package.json中引用它,以便从本地版本安装?

如何在grunt插件中运行其他注册的grunt任务?

我正在编写一个grunt插件,这将有助于我经常使用的构build过程。 我通常最终做的是将GruntFile从项目复制/粘贴到项目中,但是我认为将它放入插件可能会更有用。 我在这个构build过程中使用的任务通常是繁重的任务,比如jshint , copy , cssmin , less和cssmin等等。 我想我可以清理我的Gruntfile.js文件,如果我可以创build一个插件,只是采取了一些configuration,并运行所有这些任务。 我目前的设置通常是这样的: grunt.initConfig({ jshint: {/* … */}, copy: {/* … */}, less: {/* … */}, cssmin: {/* … */}, uglify: {/* … */} }); // Load and Register tasks… 但我想减lessinitConfig是这样的: grunt.initConfig({ build: { dev: { paths: { public: 'public', source: 'source', bower: 'bower_components' }, options: { […]

在与Yeoman一起设置AngularJS项目后,发布“npm install”

我的问题出现在angular度项目的创build之后(甚至在此期间): yo angular 在安装package.json(yo angular运行的“ npm install ”)中的所有devDependencies的过程中,我注意到node_modules文件夹中缺less一些模块。 所以,我再次下载了“npm install name_of_the_module –save-dev”(所以它们将下载并包含在devDependencies选项的package.json中)。 但例如,如果我删除node_modules文件夹,并执行命令npm安装它将开始安装,但会错过一些模块,有时缺less的模块不同于上次运行的npm安装。 我不知道如何面对这个,因为我需要为团队build立项目,他们将要做的第一件事就是执行npm install&bower install (最后一个工作正常)。 package.json的内容是: { "name": "angular_test", "version": "0.0.0", "dependencies": {}, "devDependencies": { "grunt": "^0.4.5", "grunt-autoprefixer": "^0.7.6", "grunt-concurrent": "^0.5.0", "grunt-contrib-clean": "^0.5.0", "grunt-contrib-concat": "^0.4.0", "grunt-contrib-connect": "^0.7.1", "grunt-contrib-copy": "^0.5.0", "grunt-contrib-cssmin": "^0.9.0", "grunt-contrib-htmlmin": "^0.3.0", "grunt-contrib-imagemin": "^0.8.1", "grunt-contrib-jshint": "^0.10.0", "grunt-contrib-uglify": "^0.4.1", "grunt-contrib-watch": "^0.6.1", "grunt-filerev": "^0.2.1", […]

软件包grunt不满足其兄弟的peerDependencies要求

我试图创build我的咕噜生成,但卡在以下错误 npm WARN package.json Dependency 'grunt' exists in both dependencies and devDependencies, using 'grunt@~0.4.2' from dependencies npm ERR! Darwin 13.4.0 npm ERR! argv "node" "/usr/local/bin/npm" "install" npm ERR! node v0.12.0 npm ERR! npm v2.5.1 npm ERR! code EPEERINVALID npm ERR! peerinvalid The package grunt does not satisfy its siblings' peerDependencies requirements! npm ERR! peerinvalid Peer […]

NPM未能转换SASS

我想通过grunt.js和npm将我的style.scss (其中有一些其他文件链接到它,如_variable.scss , _mixins.scss )文件转换为CSS。 但是我得到这个错误: Error: File to import not found or unreadable: compass. on line 5 of sass/style.scss 1: // typorgraphy 2: @import "base/typography"; 3: 4: // compass 5: @import "compass"; 6: 7: // import files 8: @import "base/import"; 9: 10: // mixins 这是我的gruntfile.js : module.exports = function(grunt) { // Project configuration. grunt.initConfig({ […]

任务创build文件/文件夹,当它们不存在于咕噜声

我试图自动化我的testing,并希望自动创build任何在src文件夹上创build的JavaScript的testing文件。 这是我的文件夹结构的细分。 js –src –sum.js –subtract.js –calculator.js –innerFolder –multiply.js –divide.js –specs 所以从上面的文件夹结构我想要做的是创build所有的文件夹结构和文件,只有当目标文件夹中的文件不存在时 ,我这样的规格: – js –src –sum.js –subtract.js –calculator.js –innerFolder –multiply.js –divide.js –specs –sumSpec.js –subtractSpec.js –calculator.js –innerFolder –multiplySpec.js –divideSpec.js 我解决这个问题的方法是观察src文件夹中的所有文件/文件夹: watch:{ src : { files: ['src/**/*.*'], tasks: //create files and folders on specs folders here } 我遇到了grunt.file插件,也考虑了grunt-shell ,并使我自己的脚本来实现这一点。 但我想知道是否已经有一个更简单的方法来做到这一点。

如何将一个项目variablesconfig.get()放到Grunt中的任务initConfig中?

在Grunt中,我有一个自定义的多任务从HTML文件中提取path,并使用grunt.config.set()将这些find的path添加到名为“pathsfound”的configuration数组中。 我想使用grunt.config.get()来访问这些path,以便我可以使用它们来连接,uglify等。 Gruntfile.coffee pathfinder: dist: files: [ expand: true cwd: '<%= yeoman.app %>' src: '*.html' ] concat: dist: src: grunt.config.get('pathsfound') dest: 'stuff.js' 我的注册任务如下所示: grunt.registerTask 'dist', ['pathfinder:dist', 'concat:dist'] 但是,concat任务给了我一个TypeError: Cannot call method 'indexOf' of undefined错误的TypeError: Cannot call method 'indexOf' of undefined ,提示grunt.config.get()在initConfig中找不到pathsfoundvariables。 有没有办法在initConfig阶段延迟加载configurationvariables?

Grunt-contrib-connect:如何在指定的浏览器中启动服务器

我对于凉亭 / 咕噜 / 野人环境来说是相当新颖的。 我试图自定义由默认的yeoman Webapp生成器生成的应用程序。 基本上,当我启动grunt serve ,默认浏览器将会启动,打开grunt服务器提供的URL。 我想指定在哪个浏览器应该打开Web应用程序,但我没有运气。 这些是gruntfile中连接任务(使用grunt-contrib-connect )的默认选项: connect: { options: { port: 9000, open: true, livereload: 35729, // Change this to '0.0.0.0' to access the server from outside hostname: 'localhost', } 我试图添加字段appName: 'Firefox'但我认为这不是我正在寻找。 我想应用程序名是用来指定如何从命令行(例如open命令)的默认浏览器,是吗? 是否有可能在grunt-contrib-connect中指定浏览器或根本不指定? 如果不是我该如何完成这个任务? 也许用grunt-open ? 谢谢

如何解决错误信息“Can not find module'abbrev'

我的问题是非常类似于如何解决使用Node.js“无法find模块”错误? 但是我不能用答案中提供的信息来解决我的问题。 我尝试运行UNCSS grunt插件,但是当我尝试安装它( npm install grunt-uncss –save-dev )时,出现以下错误: $ npm install grunt-uncss –save-dev module.js:340 throw err; ^ Error: Cannot find module 'abbrev' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.<anonymous> (/usr/local/Cellar/node/0.10.20/lib/node_modules/npm/node_modules/nopt/lib/nopt.js:10:14) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) 基于上面提到的答案,我试着安装这个'abbrev'模块,无论是在项目文件夹,并在全球范围内,但这产生了完全相同的错误:( npm […]