Tag: 吞咽

Gulp在我的macOS上没有成功运行

My Advanced Gulp Workflow for WordPress Themes 我正在学习本教程,并使用他在教程中提供的gulfile.js,但是当我安装 npm install 我收到了很多问题,所以我更新了文件。 但是当我实例化 glup 在我的macOSterminal,它给了我下面的错误,并拒绝成功运行命令。 [Browsersync] Serving files from: ./ [Browsersync] Watching files… [23:36:59] gulp-notify: [Gulp notification] Custom scripts task complete [23:36:59] Finished 'scriptsJs' after 388 ms [23:36:59] gulp-notify: [Gulp notification] Vendor scripts task complete [23:36:59] Finished 'vendorsJs' after 405 ms [23:36:59] Starting 'default'… [23:36:59] Finished […]

将所有html模板转换为单个对象,并将其存储在一个js文件中

在我的项目中,我保持所有的html文件有组织的方式,使我能理解。 现在,我将它们保存在template文件夹中,类似于以下所示: template –> Dashboard –> left-content.html –> right-content.html –> Analytics –> graph-section.html –> profile –> basic-profile.html –> advanced-profile.html 我希望这些文件被压缩,并添加为名称templates.js的不同js文件的键值 我想要的是这样的: templates.js var templates = { left-content: "html markup here", right-content: "html markup here", graph-section: "html markup here", basic-profile: "html markup here", advanced-profile: "html markup here" } 所以,以后使用任何模板插件如lodash ,我可以很容易地渲染。 例如: var template = _.template(templates['left-content']); var […]

正则expression式在文本文件中匹配文件名

使用Node.js,我parsing一个文件并build立一个find的图像名称的数组。 我想知道是否有人可以帮我打孔在我的正则expression式。 到目前为止,我还没有能够打破它。 var filename = (line.match(/((?:((?:[^\r\n\t\f\/])*)\.(?:(png|gif|jpe?g|pdf|xml|apng|svg|mng)\b)))/gmi) || []).pop();

带有through2的我的gulp插件以奇怪的类似于XML的格式返回文件

我正在为Gulp编写插件,为了处理文件,我需要得到它的完整path。 我使用了through2包,然后准备了processFile(file)函数,但是作为through2的一个参数,它接收的是类似奇怪的XML格式的文件,而不是像file.path , file.encoding等对象。 当通过2按以下格式返回每个文件时,如何接收file.path: <File "relative/path/to/file/aaa.js" … 完整代码: var through = require('through2'); module.exports = function() { return through.obj(function(file, encoding, callback) { function processFile(file){ console.log(file); // returns <File "relative/path/to/file/aaa.js" … } callback(null, processFile(file)); }); };

第一次吞噬用户,不能build立骨架项目。 我没有看到这个错误在networking上的其他任何东西

嗨,这是我第一次使用gulp,我正在尝试使用typescript / gulp / express来形成一个RESTful web服务。 我为此find了一个框架项目,但是当我尝试构build它时,出现错误。 这里是项目的链接: https : //github.com/idanov/express-ts-rest Kevins-Mac-Pro:express-ts-rest kevincmanning$ gulp buildAll { file: undefined, start: undefined, length: undefined, messageText: 'Failed to parse file \'src/tsconfig.json\': text.charCodeAt is not a function.', category: 1, code: 5014 } { file: undefined, start: undefined, length: undefined, messageText: 'Failed to parse file \'tests/tsconfig.json\': text.charCodeAt is not a […]

是否有可能要求从您的项目目录以外的模块没有相对path?

我试图build立一个JS模块的本地库在节点项目中使用。 如果一个新项目存在于/Users/me/projects/path/to/new/project/而且我的库文件位于/Users/me/projects/library/*.js中,有没有办法在不使用相对path? 在/Users/me/projects/path/to/new/project/app.js你可以这样要求foo.js: var foo = require('../../../../../library/foo') ,这样可以工作,但是很笨重,如果文件移动了,你必须更新你的相对path。 我已经试过requireFrom和app-module-path没有运气,因为它们是相对于项目根目录。 任何想法如何从您的项目之外要求文件目录? 提前致谢!

如何findgulp.dest()中父目录的path?

我是Gulp的新来者,当我尝试将我的文件输出到他们父母的path时,我得到了股票。 我的目录是这样的: app/page_a/less/a.less app/page_a/css 我的目标是: app/page_a/less/a.less app/page_a/css/a.css 这是我在做什么: 我使用**是因为我想匹配我所有的page_ *模块。 gulp.task('test', function () { var files = ['./app/**/*.less']; return gulp.src(files, { base: '.' // Now the base url becomes where the *.less is. }) .pipe(less()) .pipe(gulp.dest('.')); }); 我的结果:(这显然是错误:() app/page_a/less/a.less app/page_a/less/a.css app/page_a/css 那么我怎样才能输出*.css到相应的app/page_*/csspath?

同时运行gulp&express

设置Gulp,设置节点,表示。 我正在跑步,正在看我的任务。 设置快递,它运行在3001端口,默认的Gulp是3000? 我去localhost:3000,我看到我的index.html,我去localhost:3001(快递端口),我也看到index.html,但没有CSS。 这里发生了什么,我怎样才能在一个端口上工作呢? 可能吗? 我只是保持吞咽和节点服务器运行? js很新。 这里的文件: 的package.json { "name": "hour-hour", "version": "0.0.1", "private": true, "description": "Find the best local happy hours and drink specials near you.", "main": "server.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "Corey Maret", "license": "ISC", "devDependencies": { "browser-sync": "^2.12.3", "del": "^2.2.0", "express": […]

使用.ts,.scss,.html复制和观看文件夹

我开始使用VS 2015与NPM和Gulp一起学习使用TypeScript的Angular2。 我有这样的文件夹结构: scripts login login.html login.scss login.ts home home.html home.scss home.ts app.ts boot.ts 我想让Gulp观察脚本文件夹,编译文件并将它们复制到另一个目录。 所以我想要这个输出: wwwroot login login.html login.css login.js home home.html home.css home.js app.js boot.js 我怎样才能做到这一点? 谢谢

build立和注入文件只能在改变吞咽

我使用gulp注入和哈希发生器来build立我的JavaScript文件,每次都有独特的名称,以避免caching问题。build设之前,我运行gulp-clean删除以前的生成器JavaScript文件。 问题是,现在每次运行npm时,即使源代码中没有任何更改, 构build文件也正在重build。 我想在运行clean和inject之前检查源文件中是否有改变。 我认为改变了解决scheme,但不知道如何使它与散列和清理工作。 我的部分实现看起来像这样。 gulp.task('clean-scripts', function () { // return del(['./static/js/**/*.js']) return gulp.src(['./static/js/temp/**/*.js', './static/css/**/style-*.css'], {read: false}) .pipe(clean()); }); gulp.task('index', function () { var target = gulp.src('./templates/base.html'); // It's not necessary to read the files (will speed up things), we're only after their paths: var sources = gulp.src(['./static/js/temp/**/*.js', './static/css/'+cssFileName], {read: false}, {relative : true}); […]