gulp

How can I write a simple gulp pipe function?

半腔热情 提交于 2019-11-28 19:05:10
I've been trying for a day to write two pipe functions, one that compiles less files and another one that concats these files. I want to learn how to write transform streams/pipes for more complex plugins. So I want to know how to read data from another pipe, and how to alter that data and send it to the next pipe. This is what I have so far: gulp.src(sources) .pipe(through.obj(function (chunk, enc, cb) { var t = this; // console.log("chunk", chunk.path); fs.readFile(chunk.path, enc, function (err,data) { if (err) { cb(err); } less.render(data, { filename : chunk.path, sourceMap : {

How to make BrowserSync work with an nginx proxy server?

此生再无相见时 提交于 2019-11-28 18:55:24
(If needed, please see my last question for some more background info.) I'm developing an app that uses a decoupled front- and backend: The backend is a Rails app (served on localhost:3000 ) that primarily provides a REST API. The frontend is an AngularJS app, which I'm building with Gulp and serving locally (using BrowserSync ) on localhost:3001 . To get the two ends to talk to each other, while honoring the same-origin policy , I configured nginx to act as a proxy between the two, available on localhost:3002 . Here's my nginx.conf: worker_processes 1; events { worker_connections 1024; } http

Browserify - multiple entry points

耗尽温柔 提交于 2019-11-28 18:38:50
I am using Browserify within gulp. I am trying to compile down my tests to a single file as well. But unlike my main app, which I have working just fine, I am having trouble getting the tests to compile. The major difference is the tests have multiple entry points, there isn't one single entry point like that app. But I am getting errors fro Browserify that it can't find the entry point. browserify = require 'browserify' gulp = require 'gulp' source = require 'vinyl-source-stream' gulp.task 'tests', -> browserify entries: ['./app/js/**/*Spec.coffee'] extensions: ['.coffee'] .bundle debug: true

Detect release / debug in gulp using Visual Studio 2015

让人想犯罪 __ 提交于 2019-11-28 18:37:08
I've set up an ASP.NET 5 project in Visual Studio and created a gulpfile.js which I use to build my typescript and less files. For release builds, I want to uglify and concat my javascripts, and for debug I want to include my typescript- and maps in my output folder. Is there a way to 'tell' gulp the current configuration? I've seen some mention of setting the NODE_ENV environment variable, but thus far the solutions I've seen arent optimal; they require using the command line before starting the IDE, etc. The closest solution I've seen is here: http://www.colinsalmcorner.com/post/gulp-

Error: Couldn't find preset “es2015” relative to directory “/Users/username”

核能气质少年 提交于 2019-11-28 18:30:37
I get the following error when trying to use gulp-babel: Error: Couldn't find preset "es2015" relative to directory "/Users/username" I have the es2015 preset installed globally and locally so can't see why this would be an issue. Below is my gulp set up and package.json. var babel = require('gulp-babel'); var es2015 = require('babel-preset-es2015'); gulp.task('babel', function() { return gulp.src('./app/main.js') .pipe(babel({ presets: [es2015] })) .pipe(gulp.dest('dist')); }); Package.json "devDependencies": { "babel-preset-es2015": "^6.3.13", "babel-preset-es2015-node5": "^1.1.1", "browser

How to fix ReferenceError: primordials is not defined in node

久未见 提交于 2019-11-28 18:05:08
I have installed node modules by npm install, then I tried to do gulp sass-watch in command prompt. After that I got the below response. [18:18:32] Requiring external module babel-register fs.js:27 const { Math, Object, Reflect } = primordials; ^ ReferenceError: primordials is not defined Have tried this before gulp sass-watch npm -g install gulp-cli Hassan Hodges I hit the same error. I suspect you're using node 12 and gulp 3. That combination does not work: https://github.com/gulpjs/gulp/issues/2324 A previous workaround from Jan. does not work either: https://github.com/gulpjs/gulp/issues

Use Jekyll with Gulp

99封情书 提交于 2019-11-28 17:39:42
I read about Gulp and was quite taken by the philosophy. I want to try it out for myself but I am running into a little problem. I am used to using Jekyll with Grunt and I have no idea how to get Jekyll to play nice with Gulp. I've come across this article which suggests there is no need for a Jekyll plugin when using Gulp. Unfortunately it doesn't really explain how to go about it and the example it links to doesn't help me much. Is there anyone who knows how to go about this? Read this blog post: Why you shouldn’t create a gulp plugin Then realize you can easily trigger Jekyll in vanilla

gulp基础

依然范特西╮ 提交于 2019-11-28 17:37:44
一、什么是gulp?   (一)gulp是前端项目的自动化构建工具 二、gulp的作用   (一)常用的gulp插件     1、压缩JS     2、合并文件     3、重命名文件     4、编译sass     5、压缩css     6、压缩图片 三、gulp依赖的运行环境: node.js 四、安装node.js并测试是否安装成功 五、全局安装gulp:npm install -g gulp@3 注:以下操作都必须在项目的根目录下进行操作: 六、初始化package.json文件:npm init [-y] 七、创建gulpfile.js   (一)局部安装     1、安装所需插件:npm install --save-dev 插件名     2、如:         gulp         gulp-uglify         gulp-rename         gulp-concat     3、在gulpfile.js中配置       a、通过require导入所需插件          //导入所需插件        const gulp = require('gulp'),         uglify = require('gulp-uglify'),         rename = require('gulp-rename'),       

rimraf删除gulp的模块插件

喜欢而已 提交于 2019-11-28 17:37:34
gulp安装流程、使用方法及CMD常用命令导览     一、名词介绍: Npm ——node包管理工具 一开始我不理解,包管理工具是什么鬼。后来用到的gulp也好,gulp的插件包也好,都是要在npm这个里边弄出来的。 可以理解为,一个硬盘,里边放的各种整理好的、适用于各种功能的且不重复的文件夹(插件),然后我们需要啥,就去里边摘下来。 当然也可以用它来删除插件 rimraf删除gulp的模块插件 1、安装: npm install -g rimraf (全局安装),如果安装了cnpm,也可使用 cnpm install -g rimraf 命令 2、使用:先定位目标文件夹的父级目录,然后命令行输入rimraf ***(***为需要删除的文件夹名称) //反正基于他的命令语句就有很多,常用的我先搞到这里 //其他相应的放到相应上下文中好了,本来打算单独搞一篇,但是没头没尾的,适合有基础的查字典用 //不过可以考虑整理一个“字典” Cnpm Gulp——前端自动化系统构建工具 好吧,我知道这不说人话了额,因为我刚看到这几个字也是幂次方脸懵逼。说白了就是一个“流水线工作台” Package.json——基于nodejs项目必不可少的配置文件,存放于项目跟目录,普通的json文件。 json文件内不能写注释,所以package文件内也不能有注释信息 Gulpfile.js—

Gulp browser-sync - redirect API request via proxy

一曲冷凌霜 提交于 2019-11-28 17:28:59
问题 I'm trying to redirect my API requests like this with gulp and browser-sync: gulp.task('browser-sync', function () { var files = [ '../index.html', '../views/**/*.html', '../assets/css/**/*.css', '../assets/js/**/*.js' ]; var url = require('url'), proxy = require('proxy-middleware'); var proxyOptions = url.parse('http://localhost:8000/api'); proxyOptions.route = '/api'; browserSync.init(files, { server: { baseDir: '..', middleware: [proxy(proxyOptions)] } }); }); But I get this response when