Tag: gruntjs

Sails.js + Grunt“无法find模块”错误

我试图在上网本的Win7 Starter中运行sails.js。 当我执行'帆升降机'时,我得到我想要的网页在端口:1337年,但风格文件没有被链接到它。 链接应该由Grunt.js完成,但是会抛出下面的错误。 我解释错误如下:Grunt截断应该阅读'c:\ Users \ Harry Roach …'到'c:\ Users \ Harry'的用户path。 如果这个解释是正确的,我该如何解决呢? 请注意,sails.js工作似乎完全依赖于Grunt工作,即单点故障,所以一个Grunt升级是破的sails.js是坏的。 那是对的吗? [已解决]根据Stackoverflow问题20068270 – 本地安装sails.js和/或避免在目录名称中的任何空格。 而且,是的,Grunt是sails.js中的一个单点故障。 $ sails lift error: Grunt :: module.js:340 throw err; ^ Error: Cannot find module 'c:\Users\Harry' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:901:3 info: info: info: Sails.js <| info: […]

如何设置一个grunt文件来观察和编译较less的文件

我正在尝试使用grunt在开发过程中将less量文件编译为css。 在此同时,观看并重新加载。 我写的文件是这样的: module.exports = function(grunt) { grunt.initConfig({ less: { development: { options: { compress: true, yuicompress: true, optimization: 2 }, files: { // target.css file: source.less file "public/css/bootstrap.css": "./public/less/bootstrap.less" } } }, watch: { styles: { // Which files to watch (all .less files recursively in the less directory) files: ["public/less/*"], tasks: ['less'], options: […]

使用grunt预编译服务器端的html模板

使用Grunt我想知道是否有一些现有的生成过程来预编译服务器端模板。 其实与通常的模板引擎,你经常使用的function,如“包括”,“扩展layout.html”,… … 这意味着你可以预编译你的模板,做所有可以“静态”解决的东西。 例如ect和“包含”function: a.ect <div>Hello I'm <%= @name %></div><% include 'b.ect' %> b.ect <div>I'm included in a.ect</div> 由于没有条件dynamic语句来决定是否包含b.ect块, 所以a.ect可以被静态编译,包括b.ect到./dist/a.ect中 : <div>Hello I'm <%= @name %></div><div>I'm included in a.ect</div> 正如你所看到的,./ dist/a.ect仍然是一个模板,并且@namevariables仍然需要提供,所以在这种情况下,这个部分保持不变。 然而,包含是静态的,所以可以立即完成,避免在运行时无用的包含(即使有caching) 使用这种方法,我们甚至可以考虑在这个构build过程中缩小模板,等等。 为了缩小任务,我知道像htmlmin这样的工具,但是这是面向有效的html。 我还发现了一些grunt任务( grunt-ect , grunt-contrib-jade等),通过提供上下文将你的模板编译成html。 但是,它似乎希望得到您的模板的所有dynamic部分,即所有variables的值。 任何想法,如果这种预编译工具已经存在的模板引擎甚至没有咕噜? PS:这可能是一个坏的方法,所以任何build议是值得欢迎的。

咕噜咕噜地看着咖啡和玉石文件

我想同时观看我的咖啡和咕噜声文件。 当我只是看咖啡文件没有问题,但是当我添加一个玉观察员到我的文件观察员只编译一次 ,虽然有一个更新,观察员没有编译这些新的更新。 任何帮助表示感谢: 这里是我的系统中只有咖啡监视器的时候: 每当咖啡文件有更新时编译: Gruntfile.coffee module.exports = (grunt) -> grunt.initConfig pkg : grunt.file.readJSON "package.json" coffee : compile : options : sourceMap: on files : ['dist/client/js/main.js': 'client/app/scripts/app.coffee', 'server.js': 'server.coffee'] watch : coffee : options : atBegin: yes files : [ 'client/scripts/*.coffee', 'client/scripts/controllers/*.coffee', 'server.coffee'] tasks : ['coffee', 'jade'] grunt.loadNpmTasks 'grunt-contrib-coffee' grunt.loadNpmTasks 'grunt-contrib-watch' grunt.registerTask 'default', ['watch'] […]

使用grunt-shell和grunt-ssh运行的Grunt同步任务

我有一段时间试图完成我正在运行的部署脚本。 它可能有一半的时间,这是令人沮丧的,因为我主要使用我没有写的代码。 我真的希望有一个较低级别的解决方法,我可以执行。 基本上发生了什么是我试图做5个任务,最终发生asynchronous。 似乎没有一个合理的方法来阻止他们。 那些是 一个静态的文件构build/编译过程 压缩过程 一个ftp传递过程 一个解压缩过程 权限pipe理和重新链接过程 有时,压缩过程通过构build/编译过程中途发生,有时ftp传递失败,有时重链过程尝试链接到尚不存在的接收端的文件夹,并且失败。 有没有人使用grunt进行部署? 有什么build议可以用来解决这个废话? 这完全毁了我。

grunt-init-copy分组子任务

我正在尝试使用grunt copy来完成两个单独的任务。 我不需要同时运行两套,所以我试图把它们分开。 我想复制所有的字体,或复制所有的全局图像。 我正在为Windows的networking应用程序工作,每个页面都是自己的网站,所有它自己的JS,CSS等。 将所有全局图像复制到构build文件夹中 将所有全局字体复制到生成文件夹 文件夹结构 ~ Project |– app | |– fonts | |– images | | |– global | |– php, styles, js, etc |– build | |– page1 | | |– fonts | | |– images | | | |– global | | |– html, css, js, etc 我曾经希望设置一个grunt copy:images和grunt […]

Grunt registerTask()不在列表中运行任务

我已经添加了以下registerTask调用这个Gruntfile.js grunt.task.registerTask('runDebug', 'Run the app with debug flag', function() { var done = this.async(); grunt.util.spawn({ cmd: 'node', args: ['–debug', './node_modules/nodemon/nodemon.js', 'index.js'], opts: { stdio: 'inherit' } }, function (error, result, code) { if (error) { grunt.log.write (result); grunt.fail.fatal(error); } done(); }); grunt.log.writeln ('node started'); grunt.util.spawn({ cmd: 'node-inspector', args: ['&'], opts: { //cwd: current working directory […]

在testing中configuration一个单独的Grunt实例

我一直在写一个小的咕噜插件,现在我被卡住了试图端到端的插件testing。 我想完成的是这个 编写一个testing用例,为我的插件configuration一个最小的gruntconfiguration的grunt实例,并运行该任务 testing生成的文件是否等于预期的输出 运行grunt nodeunit时自动运行该testing 到目前为止,我似乎一直在configuration一个单独的Grunt实例,因为新实例似乎与已经加载的Grunt实例共享configuration。 在我的plugin_test.js有这样的东西 var testGrunt = require('grunt'); exports.codekit = { setUp: function(done) { testGrunt.initConfig({ myPlugin : { // the config } }); testGrunt.task.run(['myPlugin']); done(); }, basic_parsing_works: function(test) { test.expect(1); // no idea what this does test.equal(1,1,'basic test'); //var actual = testGrunt.file.read('tmp/test01_result.html'); //var expected = testGrunt.file.read('expected/test01_expected.html'); //test.equal(actual, expected, 'should parse file.'); […]

Grunt手表在转换成css的同时立即停止

我有一个轻微的问题,咕噜,less和文件观看。 我用grunt编译我的较less的代码到压缩的css代码。 我的代码工作正常约一分钟,然后进程不会编译我的less文件,我必须closuresterminal在我的Mac,并再次启动咕噜声进程。 rest后,你会发现我的Gruntfile.js和我的terminal读数。 我希望你能帮助我:)谢谢你的时间! 最好的祝福! Gruntfile.js: module.exports = function(grunt) { grunt.initConfig({ less: { development: { options: { compress: true, yuicompress: true, optimization: 2 }, files: { "assets/css/style.css": "assets/less/style.less" } } }, watch: { styles: { files: ['assets/**/*.less'], tasks: ['less:development'], options: { nospawn: true } } } }); grunt.loadNpmTasks('grunt-contrib-less'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.registerTask('default', [ 'less:development', 'watch' ]); […]

jsdoc不能正确生成目录

我正在运行grunt jsdoc模块,输出html缺less目录中的文件名。 见图: 注意js在modules右边的列中重复 文件顶部(AMD): /** @module identity.js * * abstracts the logic for obtaining a user's identity * @module identity.js * @type {Core} */