gulp

Gulp less not handling includes properly, included variables not defined

守給你的承諾、 提交于 2019-11-30 01:41:02
I am using less and Grunt, and am moving to gulp. My less works. When I run: lessc public/less/myapp.less I get working output with no errors. All my less, including includes, is in public/less , BTW. Here is my gulpfile: var gulp = require('gulp'); var prefixer = require('gulp-autoprefixer'); var less = require('gulp-less'); gulp.task('compileLess', function () { gulp .src('./public/less/*') .pipe(less({ paths: ['./public/less'], // Search paths for imports filename: 'myapp.less' })) .pipe(gulp.dest('./public/css')); }); // The default task (called when you run `gulp`) gulp.task('default',

How to clean a project correctly with gulp?

江枫思渺然 提交于 2019-11-30 01:14:08
On the gulp page there is the following example: gulp.task('clean', function(cb) { // You can use multiple globbing patterns as you would with `gulp.src` del(['build'], cb); }); gulp.task('scripts', ['clean'], function() { // Minify and copy all JavaScript (except vendor scripts) return gulp.src(paths.scripts) .pipe(coffee()) .pipe(uglify()) .pipe(concat('all.min.js')) .pipe(gulp.dest('build/js')); }); // Copy all static images gulp.task('images', ['clean'], function() { return gulp.src(paths.images) // Pass in options to the task .pipe(imagemin({optimizationLevel: 5})) .pipe(gulp.dest('build

How to delete compiled JS files from previous typescript(.ts) files?

前提是你 提交于 2019-11-30 00:27:31
问题 I am following Angular 2 quick start tutorial. Following is my folder structure - ├── gulpfile.js ├── index.html ├── js | ├── app.component.js | └── boot.js ├── source | ├── app.component.ts | └── boot.ts ├── node_modules ├── module 1 └── module 2 My typescript files are in source/ directory. I'm compiling it to js/ directory. I'm using gulp-typescript. The problem is when I, for example, rename the file boot.ts to bootstrap.ts and compile again, corresponding bootstrap.js file is created but

Gulp - copy and rename a file

拜拜、爱过 提交于 2019-11-30 00:04:37
问题 I'm extremely new to Gulp. I'm basically trying to watch for a modified JavaScript file, and then make a new copy of it with a new name. (eventually there'll be some processing on it, but Rome wasn't built in a day). My (naive) attempt is this: gulp.task('default', function() { return gulp.watch('../**/**.js', function(obj){ gulp.src(obj.path) .pipe(gulp.dest('foobar.js')); }); }); This takes the modified file and successfully copies it into a folder now called foobar.js. Is there anything

events.js: 141 throw er; // Unhandled 'error' event

左心房为你撑大大i 提交于 2019-11-29 23:41:45
I'm trying to run node 4.2.2 on a Mac OS and i'm not understanding why every time i get this error message: events.js:141 throw er; // Unhandled 'error' event ^ Error: spawn /Users/user/Documents/Projects/project-x/node_modules/gifsicle/vendor/gifsicle ENOENT at exports._errnoException (util.js:874:11) at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32) at onErrorNT (internal/child_process.js:344:16) at doNTCallback2 (node.js:441:9) at process._tickCallback (node.js:355:17) c12320:project-x user$ What's going wrong? If i run "gulp build" there is this output: c12320

gulp报错The following tasks did not complete

柔情痞子 提交于 2019-11-29 22:42:18
代码如下: //引用gulp模块 const gulp = require('gulp'); //使用gulp.task()建立任务 gulp.task('first', () => { console.log('第一个gulp任务执行了'); //要处理的文件 //将处理后的文件输出到dist目录下 gulp.src('./src/css/base.css') .pipe(gulp.dest('./dist/css')); }); 报错: [01:26:16] The following tasks did not complete: first [01:26:16] Did you forget to signal async completion? 原因: 这是gulp4.0版本使用task时,回调函数使用匿名函数带来的问题,gulpgulp不再支持同步任务 解决方案有很多具体参考 https://www.gulpjs.com.cn/docs/getting-started/async-completion/ 比较简单的方法就是 添加callback,来指示函数完成 即代码修改为: //引用gulp模块 const gulp = require('gulp'); //使用gulp.task()建立任务 gulp.task('first', (cb) => { console

How to minify ES6 functions with gulp-uglify?

核能气质少年 提交于 2019-11-29 22:12:25
When I run gulp I get the following error: [12:54:14] { [GulpUglifyError: unable to minify JavaScript] cause: { [SyntaxError: Unexpected token: operator (>)] message: 'Unexpected token: operator (>)', filename: 'bundle.js', line: 3284, col: 46, pos: 126739 }, plugin: 'gulp-uglify', fileName: 'C:\\servers\\vagrant\\workspace\\awesome\\web\\tool\\bundle.js', showStack: false } The offending line contains an arrow function: var zeroCount = numberArray.filter(v => v === 0).length I know I can replace it with the following to remedy the minification error: var zeroCount = numberArray.filter

events.js:160 throw er; // Unhandled 'error' event

江枫思渺然 提交于 2019-11-29 21:28:22
The project I worked on was built with gulp. Recently I updated the node version to v6.3.1. Then something came wrong. A task named 'html' throws an error. Here is the part of error code of it. bogon:toClient work$ gulp html (node:2519) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version. [10:26:10] Using gulpfile ~/Project/TIME_Cancer_Treatment_Centers_of_America(CTCA)/toClient/gulpfile.js [10:26:10] Starting 'html'... (node:2519) fs: re-evaluating native module sources is not supported. If you are using

Gulp browser-sync - redirect API request via proxy

 ̄綄美尐妖づ 提交于 2019-11-29 21:25:44
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 a call is sent to the API: Error: connect ECONNREFUSED at errnoException (net.js:904:11) at Object

what does gulp-“cli” stands for?

蹲街弑〆低调 提交于 2019-11-29 21:24:58
Can someone please explain what exactly are the differences between the following two methods of gulp installation: $ npm install --global gulp-cli and $ sudo npm install -g gulp It looks to me that both do the same thing except that the first method gives me a version 1.2.1, and the later gives me version 3.9.1 Can someone put into simple terms what exactly are the differences? and plus what is "cli" stands for? N. Brun The goal of gulp-cli is to let you use gulp like a global program, but without installing gulp globally. For example if you installed gulp 3.9.1 globally and your project