Tag: gruntjs

尝试安装grunt-sass时,“node build.js”失败

我试图从grunt-contrib-sass切换到grunt-sass,但是我正在运行与grunt包装器模块中的node-sass相关的构build错误。 到目前为止,我已经将节点从0.10.40升级到0.12.7,并切换到Python 2.7以绕过其他一些节点,但这仍然是: $ npm install > node-sass@1.0.3 install /var/www/html/example.com/www/node_modules/grunt-sass/node_modules/node-sass > node build.js child_process: customFds option is deprecated, use stdio instead. make: Entering directory `/var/www/html/example.com/www/node_modules/grunt-sass/node_modules/node-sass/build' CXX(target) Release/obj.target/binding/binding.o cc1plus: error: unrecognized command line option "-std=c++11" cc1plus: error: unrecognized command line option "-std=c++11" make: *** [Release/obj.target/binding/binding.o] Error 1 make: Leaving directory `/var/www/html/example.com/www/node_modules/grunt-sass/node_modules/node-sass/build' gyp ERR! build error gyp […]

在grunt / uglify中合并IIFE

uglify(或其他节点包,如果需要的话)有办法把我所有的IIFE结合成一个单一的IIFE吗? 在我的项目中,我们将每个文件写入一个IIFE中,并将单个全局文件作为parameter passing给IIFE。 使用最精简的JS,具有“使用严格”指令的IIFE是31 bytes ( a是我们的单个全局)。 (function(a){"use strict";/* code here */}()); 这意味着如果我们有20个源文件,我们最终会有600个字节的浪费空间。 如果我们有100个源文件,就浪费了3100字节…

grunt-newer不能用grunt-sass工作

我正在尝试使用grunt-newer来更改我的sass部分,然后运行grunt-sass任务。 出于某种原因,似乎没有注册任何更新。 哎呀! 示例目录结构: sass – components _breadcrumb.scss – helpers _variables.scss main.scss Sassconfiguration: files: [{ expand: true, cwd: 'static/sass', src: ['*.scss'], // src: ['**/*.scss'], dest: 'static/styles', ext: '.css' }] main.scss包含用于读取部分的@imports。 运行grunt newer:sass将查找对main.scss的更改。 更新globbing规则以使用** / *。scss在任何文件中根本不会进行任何更改。 这感觉就像一个混乱的问题,但我不能破解它。 任何帮助,将不胜感激。

在Ember.js中预编译模板

我正在创build一个带有Node后端的Ember项目,并希望将我的模板作为单独的文件,而不是将它们内联在index.html文件中。 我已经阅读了很多文章解释这一点,但是我仍然无法把头脑包裹在整个过程中,以及index.html文件等等什么时候完成。 咕噜是最有效的做这样的事情? 这是我的grunt文件的样子。 Gruntfile.js: grunt.loadNpmTasks('grunt-ember-templates'); grunt.registerTask('build', ['emberTemplates', 'concat', 'uglify']); //pass the compiled templates into your concat and uglify tasks. Don't worry, they don't care if they are mushed altogether // with the following task in the Grunt.config emberTemplates: { compileComponents: { options: { templateBasePath: /templates\// }, files: { 'build/precompile/components.js': 'templates/components/*.hbs' } }, compileRoutes: { […]

在生产模式下的帆升降机不起作用

当我尝试使用sails lift –prod升降帆提升帆应用程序 – 它在production.js文件中给出错误。 说Warning: Uglification failed. Unexpected character '#'. Line 12432 in .tmp/public/concat/production.js Warning: Uglification failed. Unexpected character '#'. Line 12432 in .tmp/public/concat/production.js 我search,发现它来自我的资产的js文件 #!/usr/bin/env node 当我删除这条线,并尝试做帆升降机 – 它得到的stucks 不知道错误是什么。 谁能帮我?

使用量angular器webdriver-manager运行一个任务后,Grunt停止

我目前正在试图将一些量angular器E2Etesting绑定到咕噜声。 到目前为止,还没有那么成功。 我所能find的所有文件都说咕噜声应该适合我的情况。 但是,在运行webdriver-manager update –standalone ,grunt退出而没有错误消息或者运行任何其他任务。 我的Gruntfile: 'use strict'; module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), protractor: { options: { configFile: "./conf.js", // Default config file keepAlive: true, // If false, the grunt process stops when the test fails. noColor: false, // If true, protractor will not use colors in its output. args: { […]

如何debugging通过Grunt构build的Connect服务器的请求?

我有一个咕噜的任务,build立一个连接服务器,连接到它挂起。 我想知道如何去debugging这个连接。 它启动服务器而不会抛出错误,所以我没有在我的terminal窗口中运行Grunt任务。 但没有要求回来。 我尝试用'–debug'标志运行grunt,并打印出[D] server GET /api/loginRequest/ – – – – ms但这就是它。 我也试着把代码放在中间件中,connect.js提前做出响应,但是这并不能削减它。 我的连接任务的initConfig如下所示: connect: { mockServer: { options: { livereload: true, port: 7770, hostname: 'localhost', middleware: [ function (connect, opt) { var mocker = require('connect-api-mocker-adv'), options = { urlRoot: '/api', pathRoot: 'mocks' }; return [mocker(options)]; } ] } } },

parsing包含\ $的JSON文件会导致奇怪的行为

情况: 我在获取JSON文件中的用户名string时遇到困难,需要使用正确的值parsingJavascript对象。 这是一个棘手的任务,所以它使用JSON.parse()的node.js实现。 我们有一个FTP用户名(由azure提供,不可更改),格式为"domain\$username" 。 我们需要一个Grunt任务来为FTP推送提供这个用户名格式。 我们试过的: 我已经启动了一个节点的实例,并运行了不同级别的反斜杠转义,看看如何处理这个。 (格式: Input => Parse Result ) { "user": "domain\$username" } => { user: 'domain$username' } (看起来像\ escapes $) { "user": "domain\\$username" } => Unexpected token $ (好像$需要被转义) { "user": "domain\\\$username" } => Unexpected token $ (什么?!?) { "user": "domain\\\\$username" } => { user: 'domain\\$username' } (所以反斜线被转义了,现在$不需要转义) { […]

npm npm_folder gruntfile相对根path规范

我想在我的节点操作在lib文件夹和我的项目结构是这样的, SRC LIB node_modules 的package.json Gruntfile.js DOC 所以我正在使用concat任务, module.exports = function(grunt){ grunt.initConfig({ concat: { dist: { src: ['../src/js/controller.js', '../src/js/service.js'], dest: '../dist/js/built.js', }, }, }); grunt.loadNpmTasks('grunt-contrib-concat'); } 这wokrs和dist文件夹中创buildbuilt.js文件。 但是我应该使用“../”所有的path,我会有这么多的configuration。 我可以在Gruntfile.js中只将它设置为根path一次吗 ? 有没有像{root:"../"}这样的设置?

来自phantomJS的POST调用不会使服务器从咕噜声中运行

这是我的设置。 我有一个咕task任务,做2件事情:1)启动一个HTTP服务器监听某个端口2)触发另一个咕task任务 上面触发的grunt任务是在PhantomJS的test-index.html页面上运行testing的testem任务。 test-index.html页面在第一个grunt任务中启动服务器的端口上发送一个POST调用。 问题:POST调用不会打到我的服务器。 注意:如果我手动运行同一个服务器(不是从grunt)然后运行testinggrunt任务,POST调用命中服务器。 这里是代码: 咕task任务 grunt.registerMultiTask('coverage', 'Generates coverage reports for JS using Istanbul', function () { var server = http.createServer(function(req, resp) { resp.setHeader("Access-Control-Allow-Origin", "*"); console.log('Got something'); req.pipe(fs.createWriteStream('coverage.json')) resp.end(); }); var port = 7358; server.listen(port); // This task simply executes a command: `testem.js ci` grunt.task.run('testem').then(function() { server.close(); }); }); test-index.html(在某处) function onTestemLoad() { […]