what does gulp-“cli” stands for?

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 testGulp4 has gulp 4.0 installed locally, what would happen if you run gulp -v into testGulp4? Without gulp-cli globally installed : CLI version 3.9.1 In … Read more

Does a gulp task have to return anything?

If you do not return a stream, then the asynchronous result of each task will not be awaited by its caller, nor any dependent tasks. For example, when not returning streams: $ gulp scripts [21:25:05] Using gulpfile ~/my-project/gulpfile.js [21:25:05] Starting ‘tsc’… [21:25:05] Finished ‘tsc’ after 13 ms [21:25:05] Starting ‘scripts’… [21:25:05] Finished ‘scripts’ after 10 … Read more

How to inject content of CSS file into HTML in Gulp? [closed]

You could easily use gulp-replace, like so: var gulp = require(‘gulp’), replace = require(‘gulp-replace’), fs = require(‘fs’); // in your task return gulp.src(…) .pipe(replace(/<link href=”https://stackoverflow.com/questions/23820703/style.css”[^>]*>/, function(s) { var style = fs.readFileSync(“https://stackoverflow.com/questions/23820703/style.css”, ‘utf8’); return ‘<style>\n’ + style + ‘\n</style>’; })) .pipe(gulp.dest(…)); You can also easily modify the replacement RegEx to work with different files, too. return … Read more

Gulp condition inside pipe

Use the gulp-if plugin: var gulpif = require(‘gulp-if’); g.task(‘sass’, function() { return g.src(sources.sass) .pipe(changed(output.css)) .pipe(sass({style:’compressed’, sourcemap:true})) // Conditional output .pipe(gulpif(condition1, g.dest(output.css))) .pipe(gulpif(condition2, g.dest(output.css2))) .pipe(notify(‘scss converted to css and compressed <%= file.relative %>’)); });

Catching gulp-mocha errors

You need to ignore ‘error’ and always emit ‘end’ to make ‘gulp.watch’ work. function handleError(err) { console.log(err.toString()); this.emit(‘end’); } gulp.task(“test”, function() { return gulp.src(paths.tests) .pipe(mocha({ reporter: “spec” }) .on(“error”, handleError)); }); This makes ‘gulp test’ to always return ‘0’ which is problematic for Continuous Integration, but I think we have no choice at this time.

console.log to stdout on gulp events

(In December 2017, the gulp-util module, which provided logging, was deprecated. The Gulp team recommended that developers replace this functionality with the fancy-log module. This answer has been updated to reflect that.) fancy-log provides logging and was originally built by the Gulp team. var log = require(‘fancy-log’); log(‘Hello world!’); To add logging, Gulp’s API documentation … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)