Tag:

吞噬水龙头进入无限循环

我试图获取当前的文件名在globstream内,以便我可以将它传递给玉来正确命名我的模板。 通常它看起来像: gulp.task('templatesjs', function() { gulp.src('src/templates/*.jade') .pipe(jade({ client: true, name:"filenamehere" })) .pipe(gulp.dest('build/templates')) }); 我在网上find的唯一答案是通过使用gulp-tap来提取stream中的文件名: gulp.task('templatesjs', function() { gulp.src('src/templates/*.jade') .pipe(tap(function(file, t) { var filename = file.relative.split('.')[0]; return t.through(jade, [{client:true, name:filename}]); })) .pipe(gulp.dest('build/templates')) }); 但是由于某种原因,这个进入了一个无限循环。 如果glob匹配index.jade,例如第一个迭代的file.relative被设置为index.jade,但是它会在file.relative被设置为index.js的无限循环中被捕获,并且jade编译器崩溃试图编译index.js文件。 我知道这是因为,如果我省略客户端:true选项,file.relative是在第一次迭代index.jade和所有迭代后的index.html。 这当然不会崩溃,但会陷入一个无限循环,编译index.html到index.html。 我的解决scheme是检查文件的扩展名,只通过玉pipe道,如果我在一个包含玉文件的迭代。 这解决了无限循环,但它是sl and,它复制一个玉文件到我的build立目录(不是一个巨大的交易)。 它也只对第一个文件起作用,对所有文件起作用后都得到第一个文件的名字。 我知道我做错了什么,但我不知道是什么。 gulp.task('templatesjs', function() { gulp.src('src/templates/*.jade') .pipe(tap(function(file, t) { sourcefile = file.relative; filename = sourcefile.split('.')[0] if(sourcefile.split('.')[sourcefile.split('.').length-1]!='js') […]

在Heroku上部署Angul应用程序:应用程序崩溃

我有一个使用Gulp的Node.js + Angular web应用程序。 当我运行命令“gulp serve”时,它在我的本地机器上完美地工作。 我正在尝试在Heroku中部署它,并在网上find了一些资源,所以我做了以下工作。 我用这个内容在根目录中创build了一个名为web.js的新文件: var gzippo = require('gzippo'); var express = require('express'); var app = express(); app.use(express.logger('dev')); app.use(gzippo.staticGzip("" + __dirname + "/build")); app.listen(process.env.PORT || 5000); 我用这个内容在根目录中创build了一个名为Procfile的新文件: web: node web.js 这是package.json文件。 请注意,我已经添加了gulp serve作为启动脚本和bower install作为postinstall,因为它是在本地工作的方式。 { "name": "myapp", "version": "0.0.1", "dependencies": { "express": "^4.13.3", "bower": "1.6.5", "gzippo": "^0.2.0", }, "scripts": { "test": "gulp […]

gulpbuild立输出不在Heroku slug

我有一个在本地工作的超级简单的gulpfile: const gulp = require('gulp'); gulp.task('build:css', function() { return gulp.src('./node_modules/bootstrap/dist/css/*') .pipe(gulp.dest('./build')); }); gulp.task('build:js', function() { return gulp.src('./node_modules/bootstrap/dist/js/*') .pipe(gulp.dest('./build')); }); gulp.task('build', [ 'build:css', 'build:js' ]); gulp.task('default', [ 'build' ]); 它运行良好,并将文件复制到“构build”子文件夹。 事实上,它也运行在git push heroku master (它是package.json的一个postinstall脚本): remote: > gulp build remote: remote: [06:57:45] Using gulpfile /tmp/build_212ea9c2c3fab185469156431b6c1509/coming-soon/gulpfile.js remote: [06:57:45] Starting 'build:css'… remote: [06:57:45] Starting 'build:js'… remote: [06:57:45] Finished […]

如何在Gulp-Jade中设置默认的文档types

我在使用gulp-jade时遇到了一个问题:Jade编译器总是向HTML属性添加一个没有值的值,这会破坏我的AngularJS设置。 (例如div(ui-view)变成<div ui-view="ui-view">当我想<div ui-view> 。 这个问题不会发生在具有doctype html文件中,但是由于我主要使用的是“partials”,所以没有任何帮助。 我正在运行.pipe(jade())没有额外的选项。 显然gulp-jade支持所有的Jade API选项, 这里列出 ,但是我不知道哪一个适用于这里。

Heroku,NodeJs App,Gulp和资产修改问题

将我的NodeJs应用程序推送到Heroku时,我遇到资产修改问题。 我正计划在安装后运行我的gulp生产任务。 我的一个任务涉及修改文件(app.js – > app.6789.js)。 这意味着我必须清理对index.ejs中这些文件的引用。 问题在于Heroku的临时文件系统(其中没有写入的文件对于任何其他testing仪中的进程是可见的,并且在停止或重新启动测功机的时刻任何写入的文件将被丢弃)。 所以既然我在写完文件之后运行这个版本,很有可能会失去这个版本。 一个想法是我可以在本地编译所有这些,并推高了index.js,但至less在我的图像,他们会在那里两次,因为我压缩他们等,这增加了我的子弹大小… 我错过了关于资产修改/节点/ Gulp / Heroku的东西吗? 我似乎无法find一个解决scheme或实例发生在别人身上,这让我相信我把这个错误设置了错误,这可能是非常真实的。 谢谢你的帮助!!

玉,g玉当地人更新

是任何解决scheme来更新每个版本的玉石模板的本地人(即使看玉文件)? 现在,模板仅在第一次构build时才会获取数据。

使用Gulp,Mocha,Browserify进行正确configuration,以执行服务器端testing的客户端testing

我正在开发一个节点应用程序,利用我们的构build过程中的gulp-mocha以及我们testing运行者的gulp-mocha插件。 gulp.task('test', function () { return gulp.src(TESTJS) .pipe(mocha({reporter: 'spec'})) .on("error", function (err) { // handle the mocha errors so that they don't cloud the test results, // or end the watch console.log(err.toString()); this.emit('end'); }); }); 目前TESTJS只是我的服务器端testing。 我想要使​​用相同的过程来执行我的客户端testing。 我看了一下, gulp-blanket-mocha并给了它一枪,但我一直遇到同样的问题。 当试图testing我的主干代码时,它失败了,因为testing运行器找不到其他客户端组件(即jquery ),并且失败。 我得知我需要使用像phantomJS这样的无phantomJS webkit。 但是我真的很难搞清楚如何将这一点与browserify结合到一起。 任何人试图得到像这样的设置,或者有什么想法,我在这里失去了我的吞咽“testing”任务执行我的客户端摩卡testing以及我的服务器端?

在Chrome中使用Gulp Livereload

下面的代码似乎工作得很好,直到我去1ocalhost:8081 … 然后我收到消息 <pre>{"tinylr":"Welcome","version":"0.0.5"}</pre> 我的目录结构是…. ____gulp | |____build | | |____images | | |____index.html | | |____scripts | | |____styles | |____gulpfile.js | |____node_modules | |____src | | |____images | | |____index.html | | |____scripts | | |____styles 为什么不是我的HTML页面加载? 如果我尝试浏览到1ocalhost:8081 / build / index.html页面不会加载,我得到消息 {“错误”:“not_found”,“reason”:“没有这样的路线”} 我也尝试了铬插件,但当我点击插件时,我得到下面的味精 无法连接到LiveReload服务器。 请确保LiveReload 2.3(或更高版本)或其他兼容的服务器正在运行。 我检查了插件在Chrome浏览器的插件设置,并检查文件URL的选项 下面我的评论代码….. //sudo npm install gulp […]

如何使用Gulp和gulp-data从单一的玉石模板生成多个html文件

我正在用Gulp创build一个静态站点生成器。 我想知道如何pipe每个数据(JSON)到一个单一的玉模板产生多个HTML文件。 这里是吞咽'模板'的任务: gulp.task('templates', function () { 'use strict'; var myData = JSON.parse(fs.readFileSync('./_assets/data/content.json')); var myPages = myData.pages; var myPosts = myData.posts; gulp.src('./_assets/templates/index.jade') .pipe(data(function (file) { return myData; })) .pipe(jade()) .pipe(minifyhtml()) .pipe(gulp.dest('./_site/')) .pipe(connect.reload()); // this is my dumb attempt at trying to // output each piece of data and than // have jade create an html […]