gulp

Gulpjs combine two tasks into a single task

自闭症网瘾萝莉.ら 提交于 2019-11-29 21:14:44
I currently have two tasks, that both compile sass files. I would still like to concat the two directories into separate files but it seems that it would be more maintainable if I could simply create a 'sass' task that would be responsible for all of the sass compilation. // Compile Our Sass gulp.task('bootstrap-sass', function() { return gulp.src('./public/bower/bootstrap-sass/lib/*.scss') .pipe(sass()) .pipe(contact('bootstrap.css')) .pipe(gulp.dest('./public/dist/css')); }); gulp.task('site-sass', function() { return gulp.src('./public/app/scss/*.scss') .pipe(sass()) .pipe(contact('site.css

How can I set an environment variable as gulp task?

为君一笑 提交于 2019-11-29 21:13:26
I don't want type the extra arguments NODE_ENV='production' gulp every time I run gulp to set an environment variable. I would rather set the environment variable from within gulp via a task . What would be a good way to achieve this? gulp.task('set-dev-node-env', function() { return process.env.NODE_ENV = 'development'; }); gulp.task('set-prod-node-env', function() { return process.env.NODE_ENV = 'production'; }); Use it like: gulp.task('build_for_prod', ['set-prod-node-env'], function() { // maybe here manipulate config object config.paths.src.scripts = config.paths.deploy.scripts;

How to run bash commands in gulp?

社会主义新天地 提交于 2019-11-29 20:45:14
I want to add some bash commands at the end of gulp.watch function to accelerate my development speed. So, I am wondering if it is possible. Thanks! Use https://www.npmjs.org/package/gulp-shell . A handy command line interface for gulp Mangled Deutz I would go with: var spawn = require('child_process').spawn; var fancyLog = require('fancy-log'); var beeper = require('beeper'); gulp.task('default', function(){ gulp.watch('*.js', function(e) { // Do run some gulp tasks here // ... // Finally execute your script below - here "ls -lA" var child = spawn("ls", ["-lA"], {cwd: process.cwd()}), stdout

Best way to filter files in gulp.watch?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 20:33:22
I would like to watch all, but the .min.ext files in my directories with gulp.js . What is the best way to filter out those? Example: gulp.task('watch', function(e) { gulp.watch('./js/*.js', ['css']); // don't want to watch .min.js files. what is best way? }); EDIT: If can't be done without external packages, which one is the most reputable? gulp.watch internally uses vinyl-fs (see source ), which uses gaze , which uses itself minimatch , so you should be able to ignore some files using !./js/*.min.* . In fact, this is even described in vinyl-fs's README : fs.src(["./js/**/*.js", "!./js/vendor

Error: Cannot find module 'gulp-sass'

不打扰是莪最后的温柔 提交于 2019-11-29 20:32:51
When I compile with gulp , I got an error like below. How can I fix it? module.js:339 throw err; ^ Error: Cannot find module 'gulp-sass' at Function.Module._resolveFilename (module.js:337:15) at Function.Module._load (module.js:287:25) at Module.require (module.js:366:17) at require (module.js:385:17) at Object.<anonymous> (/Applications/XAMPP/xamppfiles/htdocs/flyscoot.com/gulpfile.js:2:12) at Module._compile (module.js:435:26) at Object.Module._extensions..js (module.js:442:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:311:12) at Module.require (module.js:366:17)

Is it possible write a gulpfile in es6?

谁都会走 提交于 2019-11-29 20:26:30
Question: How can I write my gulp file in ES6 so I can use import instead of require and use => syntax over function() ? I can use io.js or node any version. gulpfile.js: import gulp from "./node_modules/gulp/index.js"; gulp.task('hello-world', =>{ console.log('hello world'); }); Errors: import gulp from "./node_modules/gulp/index.js"; ^^^^^^ SyntaxError: Unexpected reserved word gulp.task('hello-world', =>{ ^^ SyntaxError: Unexpected token => Inside the node_modules/gulp/bin/gulp.js i've changed the first line to #!/usr/bin/env node --harmony as asked in this stack brbcoding Yes, you can by

How can I integrate Bower with Gulp.js?

余生长醉 提交于 2019-11-29 20:18:46
I am trying to write a gulp task that does a few things Install the Bower dependencies Concat those dependencies into one file in the order of the dependencies I was hoping to do this without having to specify the paths to those dependencies. I know there is the command bower list --paths but I am unsure of if it is possible to tie it together. Any thoughts? Edit So I am trying to use the gulp-bower-files and I am getting an eaccess error and its not generating the concatenated file. gulpfile.js var gulp = require('gulp'); var bower = require('bower'); var concat = require('gulp-concat'); var

Gulp Error: spawn EACCES

∥☆過路亽.° 提交于 2019-11-29 20:17:51
问题 gulpfile.js 'use strict'; var gulp = require('gulp'); gulp.paths = { src: 'src', dist: 'dist', tmp: '.tmp', e2e: 'e2e' }; require('require-dir')('./gulp'); gulp.task('build', ['clean'], function () { gulp.start('buildapp'); }); gulp/server.js 'use strict'; var gulp = require('gulp'); var paths = gulp.paths; var util = require('util'); var browserSync = require('browser-sync'); var middleware = require('./proxy'); function browserSyncInit(baseDir, files, browser) { browser = browser ===

What are the differences between Grunt, Gulp.js and Bower? Why & when to use them?

独自空忆成欢 提交于 2019-11-29 20:15:36
What are the differences between Grunt, Gulp.js and Bower? Why & when and how to to use them? I've seen nowadays, most of the front-end project use above tools, though I am using them like in my recent project I am using gulp to build HTML, CSS and JavaScript using script like $ gulp build but don't have much understanding of all these front-end frameworks, plese help me get overall understanding of Grunt, Gulp.js and Bower. In essence and with a lot of hand-waving away of details, Gulp and Grunt are both systems for automating serieses of inter-dependent tasks, commonly used for defining the

Running a shell command from gulp

白昼怎懂夜的黑 提交于 2019-11-29 20:15:30
I would like to run a shell command from gulp, using gulp-shell . I see the following idiom being used the gulpfile. Is this the idiomatic way to run a command from a gulp task? var cmd = 'ls'; gulp.src('', {read: false}) .pipe(shell(cmd, {quiet: true})) .on('error', function (err) { gutil.log(err); }); gulp-shell has been blacklisted. You should use gulp-exec instead, which has also a better documentation. For your case it actually states: Note: If you just want to run a command, just run the command, don't use this plugin: var exec = require('child_process').exec; gulp.task('task', function