gulp: gulp is sometimes slow to start
On my machine with lots of softwares (sketch, firefox as frontend dev, VMs, etc), I don’t have enough ram for gulp and its start is in this case really slow.
Once it was started, all is ok, the compilation is really fast and the next time I start gulp, it’ll be fast too.
Note : This issue is for the moment a memo, I’ll be back with more information. 😉
An indication of a compilation without troubles:
Thu 21 Aug 2014 12:08:33 CEST
[12:08:34] Using gulpfile ~/xxx/xxx/xxx/gulpfile.js
[12:08:34] Starting 'clean:dist'...
[12:08:34] Finished 'clean:dist' after 16 ms
[12:08:34] Starting 'clean:build'...
[12:08:34] Finished 'clean:build' after 252 μs
[12:08:34] Starting 'assets'...
[12:08:34] Starting 'images'...
[12:08:34] Starting 'svg'...
[12:08:34] Starting 'templates'...
[12:08:34] Finished 'assets' after 170 ms
[12:08:34] Finished 'templates' after 177 ms
[12:08:34] Starting 'scripts'...
[12:08:34] Finished 'svg' after 384 ms
[12:08:34] Starting 'styles:all'...
[12:08:38] Finished 'styles:all' after 3.92 s
[12:08:38] Finished 'scripts' after 4.15 s
[12:08:38] Finished 'images' after 4.43 s
[12:08:38] Starting 'compile'...
[12:08:38] Finished 'compile' after 9.18 μs
Thu 21 Aug 2014 12:08:38 CEST
Packages:
{
"gulp": "3.8.6",
"gulp-concat": "2.2.0",
"gulp-consolidate": "0.1.2",
"gulp-declare": "0.2.0",
"gulp-define-module": "0.1.1",
"gulp-filter": "0.5.0",
"gulp-handlebars": "2.1.0",
"gulp-iconfont": "0.1.0",
"gulp-imagemin": "0.6.1",
"gulp-jshint": "1.6.3",
"gulp-livereload": "2.1.0",
"gulp-minify-css": "0.3.5",
"gulp-myth": "0.3.1",
"gulp-plumber": "0.6.3",
"gulp-rename": "1.2.0",
"gulp-replace": "0.3.0",
"gulp-rev": "0.4.2",
"gulp-svg-symbols": "0.1.2",
"gulp-svgmin": "0.4.6",
"gulp-uglify": "0.3.1",
"gulp-util": "2.2.17"
}
gulpfile.js:
/**
* Imports
*/
var gulp = require('gulp')
var livereload = require('gulp-livereload')
/**
* Helpers
*/
var path = __dirname + '/gulp/'
/**
* Private tasks
*/
gulp.task('clean:dist', require(path + 'clean').dist)
gulp.task('clean:build', require(path + 'clean').build)
gulp.task('assets', require(path + 'assets'))
gulp.task('images', require(path + 'images'))
gulp.task('glyphicons', require(path + 'glyphicons'))
gulp.task('svg', require(path + 'svg'))
gulp.task('styles', require(path + 'styles'))
gulp.task('styles:all', ['svg'], require(path + 'styles'))
gulp.task('jshint', require(path + 'jshint'))
gulp.task('scripts', ['templates'], require(path + 'scripts'))
gulp.task('templates', require(path + 'templates'))
/**
* Public tasks
*/
gulp.task('compile', ['clean:dist', 'clean:build', 'assets', 'images', 'styles:all', 'scripts'])
gulp.task('watch', ['compile'], function() {
livereload.listen()
gulp.watch('src/frontend/assets/**/*}', ['assets'])
gulp.watch('src/frontend/images/**/*}', ['images'])
gulp.watch('src/frontend/**/{*.js, *.hbs}', ['scripts'])
gulp.watch('src/frontend/styles/**/*.css', ['styles'])
gulp.watch(['web/assets/**/*', 'resources/views/**/*.tpl']).on('change', livereload.changed)
})
node : v0.10.31
macosx : 10.9.4
An example of task:
var gulp = require('gulp')
var es = require('event-stream')
var gutil = require('gulp-util')
var imagemin = require('gulp-imagemin')
var svgmin = require('gulp-svgmin')
module.exports = function() {
var bitmap = gulp.src('src/frontend/images/**/{*.png,*.gif,*.jpg,*.jpeg}')
.pipe( gutil.env.dist ? imagemin( { optimizationLevel: 5 } ) : gutil.noop() )
var vector = gulp.src('src/frontend/images/**/*.svg')
.pipe( gutil.env.dist ? svgmin() : gutil.noop() )
return es.merge( bitmap, vector).pipe( gulp.dest('web/assets/images') )
}
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 16 (8 by maintainers)
@kud you can use time-require to figure out which require is the slowest. But the require mechanism is expensive, especially on non-SSD harddrives.