Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ReberS's avatar

Elixir extremely slow (45sec+)

Whenever I run gulp or gulp watch, Elixir is extremely slow. Absolutely no fun to use it. Logs below. Any ideas?

vagrant@scotchbox:/var/www/api.aftercare$ gulp
[08:25:06] Using gulpfile /var/www/api.aftercare/gulpfile.js
[08:25:06] Starting 'default'...
[08:25:06] Starting 'sass'...

Fetching Sass Source Files...
   - resources/assets/sass/main.scss


Saving To...
   - public/css/app.css

[08:25:27] Finished 'default' after 22 s
[08:25:29] Finished 'sass' after 23 s
[08:25:29] Starting 'scripts'...

Fetching Scripts Source Files...
   - resources/assets/bower_components/angular/angular.js
   - resources/assets/bower_components/angular-modal-service/dst/angular-modal-service.js
   - resources/assets/bower_components/angular-ui-router/release/angular-ui-router.js
   - resources/assets/bower_components/ng-remote-validate/release/ngRemoteValidate.0.6.1.js
   - resources/assets/bower_components/ngstorage/ngStorage.js
   - resources/assets/bower_components/jquery/dist/jquery.js
   - resources/assets/bower_components/bootstrap/dist/js/bootstrap.js
   - resources/assets/bower_components/underscore/underscore.js
   - resources/assets/bower_components/angular-gettext/dist/angular-gettext.js
   - resources/assets/bower_components/lodash/dist/lodash.js
   - resources/assets/js/ErrorHandler.js
   - resources/assets/js/init.js
   - resources/assets/js/app.js
   - resources/assets/js/config.js
   - resources/assets/js/routes.js
   - resources/assets/js/i18n.js
   - resources/assets/js/controllers/**/*
   - resources/assets/js/factories/**/*
   - resources/assets/js/services/**/*
   - resources/assets/js/providers/**/*
   - resources/assets/js/directives/**/*
   - resources/assets/js/filters/**/*


Saving To...
   - public/js/app.js

[08:25:37] Finished 'scripts' after 8.07 s
[08:25:37] Starting 'version'...

Fetching Version Source Files...
   - public/css/app.css
   - public/js/app.js


Saving To...
   - public/build

[08:25:37] Finished 'version' after 577 ms
Start time: (2016-04-22 08:31:53 UTC) [treshold=1%,sorted]
# [order]  module                                                               time  %
 1 [1826]  /var/www/api.aftercare/gulpfile.js (gulpfile.js)                    18.1s  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 37%
 2 [4483]  /var/www/api.aftercare/node_modu..._modules/gulp-cssnano/index.js)    16s  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 33%
 3 [4476]  cssnano (node_modules/cssnano/dist/index.js)                          16s  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 33%
 4 [5385]  /var/www/api.aftercare/node_modu...de_modules/gulp-babel/index.js)   7.5s  ▇▇▇▇▇▇▇▇▇▇▇ 15%
 5 [5384]  babel-core (node_modules/babel-core/index.js)                        7.3s  ▇▇▇▇▇▇▇▇▇▇▇ 15%
 6 [5383]  ./lib/api/node.js (node_modules/babel-core/lib/api/node.js)          7.2s  ▇▇▇▇▇▇▇▇▇▇ 15%
 7 [1587]  /var/www/api.aftercare/node_modu...el-elixir/tasks/browsersync.js)   6.3s  ▇▇▇▇▇▇▇▇▇ 13%
 8 [1563]  browser-sync (node_modules/browser-sync/index.js)                    5.8s  ▇▇▇▇▇▇▇▇ 12%
 9 [1557]  ./lib/browser-sync (node_modules/browser-sync/lib/browser-sync.js)   5.7s  ▇▇▇▇▇▇▇▇ 12%
10 [1080]  /var/www/api.aftercare/node_modu...vel-elixir/tasks/browserify.js)   4.9s  ▇▇▇▇▇▇▇ 10%
11  [506]  laravel-elixir (node_modules/laravel-elixir/index.js)                4.8s  ▇▇▇▇▇▇▇ 10%
12 [5086]  babel-types (node_modules/babel-types/lib/index.js)                  3.9s  ▇▇▇▇▇▇ 8%
13  [331]  gulp (node_modules/gulp/index.js)                                    3.2s  ▇▇▇▇▇ 7%
14 [1041]  browserify (node_modules/browserify/index.js)                        2.9s  ▇▇▇▇ 6%
15 [2887]  postcss-svgo (node_modules/postcss-svgo/dist/index.js)               2.6s  ▇▇▇▇ 5%
16 [1462]  ./sockets (node_modules/browser-sync/lib/sockets.js)                 2.6s  ▇▇▇▇ 5%
17 [1430]  socket.io (node_modules/socket.io/index.js)                          2.3s  ▇▇▇▇ 5%
18 [1429]  ./lib (node_modules/socket.io/lib/index.js)                          2.2s  ▇▇▇▇ 5%
19 [2299]  /var/www/api.aftercare/node_modu...les/gulp-autoprefixer/index.js)   2.1s  ▇▇▇ 4%
20 [2297]  autoprefixer-core (node_modules/...fixer-core/lib/autoprefixer.js)   1.8s  ▇▇▇ 4%
21  [330]  vinyl-fs (node_modules/vinyl-fs/index.js)                            1.7s  ▇▇▇ 4%
22 [5207]  ../transformation/file/options/o...file/options/option-manager.js)   1.7s  ▇▇▇ 4%
23 [1556]  browser-sync-ui (node_modules/browser-sync-ui/index.js)              1.7s  ▇▇▇ 3%
24 [1551]  ./lib/UI (node_modules/browser-sync-ui/lib/UI.js)                    1.6s  ▇▇▇ 3%
25 [3222]  autoprefixer (node_modules/autoprefixer/lib/autoprefixer.js)         1.6s  ▇▇▇ 3%
26 [1800]  /var/www/api.aftercare/node_modu...aravel-elixir/tasks/version.js)   1.4s  ▇▇ 3%
27  [663]  watchify (node_modules/watchify/index.js)                            1.4s  ▇▇ 3%
28 [5052]  babel-traverse (node_modules/babel-traverse/lib/index.js)            1.4s  ▇▇ 3%
29  [155]  gulp-util (node_modules/gulp-util/index.js)                          1.3s  ▇▇ 3%
30  [660]  chokidar (node_modules/chokidar/index.js)                            1.3s  ▇▇ 3%
31 [5031]  ./context (node_modules/babel-traverse/lib/context.js)               1.2s  ▇▇ 2%
32 [5029]  ./path (node_modules/babel-traverse/lib/path/index.js)               1.1s  ▇▇ 2%
33 [3659]  postcss-minify-selectors (node_m...minify-selectors/dist/index.js)  957ms  ▇▇ 2%
34 [1392]  socket.io-client (node_modules/socket.io-client/index.js)           948ms  ▇▇ 2%
35  [284]  ./lib/src (node_modules/vinyl-fs/lib/src/index.js)                  946ms  ▇▇ 2%
36 [1391]  ./lib/ (node_modules/socket.io-client/lib/index.js)                 910ms  ▇▇ 2%
37 [1305]  engine.io (node_modules/engine.io/lib/engine.io.js)                 896ms  ▇▇ 2%
38  [816]  module-deps (node_modules/module-deps/index.js)                     896ms  ▇▇ 2%
39 [1300]  ./server (node_modules/engine.io/lib/server.js)                     859ms  ▇▇ 2%
40 [5369]  ../transformation/pipeline (node...lib/transformation/pipeline.js)  850ms  ▇▇ 2%
41  [444]  ./Notification (node_modules/laravel-elixir/Notification.js)        822ms  ▇▇ 2%
42  [443]  gulp-notify (node_modules/gulp-notify/index.js)                     814ms  ▇▇ 2%
43 [4372]  postcss-discard-empty (node_modu...ss-discard-empty/dist/index.js)  802ms  ▇▇ 2%
44 [5368]  ./file (node_modules/babel-core/lib/transformation/file/index.js)   801ms  ▇▇ 2%
45  [441]  ./lib/extra_api (node_modules/gulp-notify/lib/extra_api.js)         792ms  ▇▇ 2%
46 [4371]  postcss (node_modules/postcss-di...modules/postcss/lib/postcss.js)  783ms  ▇▇ 2%
47 [2581]  postcss-minify-gradients (node_m...minify-gradients/dist/index.js)  776ms  ▇▇ 2%
48 [2730]  svgo (node_modules/svgo/lib/svgo.js)                                761ms  ▇▇ 2%
49 [3167]  ./prefixes (node_modules/autoprefixer/lib/prefixes.js)              755ms  ▇▇ 2%
50  [917]  browser-pack (node_modules/browser-pack/index.js)                   706ms  ▇ 1%
51 [1387]  ./manager (node_modules/socket.io-client/lib/manager.js)            696ms  ▇ 1%
52 [1175]  ./async-tasks (node_modules/browser-sync/lib/async-tasks.js)        690ms  ▇ 1%
53 [4836]  ./definitions/init (node_modules...-types/lib/definitions/init.js)  678ms  ▇ 1%
54 [2640]  postcss (node_modules/postcss-sv...modules/postcss/lib/postcss.js)  668ms  ▇ 1%
55 [1706]  del (node_modules/del/index.js)                                     667ms  ▇ 1%
56 [1174]  ./async (node_modules/browser-sync/lib/async.js)                    666ms  ▇ 1%
57 [4434]  postcss-unique-selectors (node_m...unique-selectors/dist/index.js)  656ms  ▇ 1%
58 [3485]  postcss-colormin (node_modules/postcss-colormin/dist/index.js)      654ms  ▇ 1%
59 [1172]  ./utils (node_modules/browser-sync/lib/utils.js)                    649ms  ▇ 1%
60 [2817]  ../../plugins/minifyStyles (node...s/svgo/plugins/minifyStyles.js)  648ms  ▇ 1%
61 [2816]  csso (node_modules/csso/lib/index.js)                               633ms  ▇ 1%
62 [4431]  postcss (node_modules/postcss-un...modules/postcss/lib/postcss.js)  613ms  ▇ 1%
63  [659]  ./lib/fsevents-handler (node_mod...okidar/lib/fsevents-handler.js)  609ms  ▇ 1%
64 [2255]  ./prefixes (node_modules/autoprefixer-core/lib/prefixes.js)         607ms  ▇ 1%
65  [329]  glob-watcher (node_modules/glob-watcher/index.js)                   602ms  ▇ 1%
66 [2719]  ./svgo/config.js (node_modules/svgo/lib/svgo/config.js)             601ms  ▇ 1%
67 [2575]  postcss (node_modules/postcss-mi...modules/postcss/lib/postcss.js)  591ms  ▇ 1%
68  [327]  gaze (node_modules/gaze/lib/gaze.js)                                559ms  ▇ 1%
69  [657]  node-pre-gyp (node_modules/fseve...de-pre-gyp/lib/node-pre-gyp.js)  557ms  ▇ 1%
70 [1766]  gulp-rev (node_modules/gulp-rev/index.js)                           557ms  ▇ 1%
71 [4667]  babel-runtime/core-js/get-iterat...untime/core-js/get-iterator.js)  551ms  ▇ 1%
72  [916]  combine-source-map (node_modules/combine-source-map/index.js)       550ms  ▇ 1%
73 [4594]  ../util (node_modules/babel-core/lib/util.js)                       547ms  ▇ 1%
74 [3986]  postcss-normalize-url (node_modu...ss-normalize-url/dist/index.js)  545ms  ▇ 1%
75  [432]  node-notifier (node_modules/node-notifier/index.js)                 542ms  ▇ 1%
76 [2716]  js-yaml (node_modules/js-yaml/index.js)                             538ms  ▇ 1%
77 [4666]  core-js/library/fn/get-iterator...-js/library/fn/get-iterator.js)   529ms  ▇ 1%
78 [2516]  postcss-discard-comments (node_m...discard-comments/dist/index.js)  517ms  ▇ 1%
79 [2128]  postcss (node_modules/postcss/lib/postcss.js)                       517ms  ▇ 1%
80  [323]  globule (node_modules/globule/lib/globule.js)                       508ms  ▇ 1%
81 [3853]  postcss-minify-font-values (node...ss-minify-font-values/index.js)  498ms  ▇ 1%
82 [2715]  ./lib/js-yaml.js (node_modules/js-yaml/lib/js-yaml.js)              497ms  ▇ 1%
83 [1550]  ./plugins/network-throttle/netwo...tle/network-throttle.plugin.js)  493ms  ▇ 1%
84 [2803]  ./compressor (node_modules/csso/lib/compressor/index.js)            486ms  ▇ 1%
85 [1948]  /var/www/api.aftercare/node_modu...(node_modules/gulp-if/index.js)  485ms  ▇ 1%
Total require(): 5446
Total time: 48.4s

Any help is appreciated! :)

Thanks

0 likes
8 replies
ReberS's avatar

@JoeDawson Thanks for trying to help. My gulpfile.js looks like so:

// time-require
require('time-require');

// Disable notifications
process.env.DISABLE_NOTIFIER = true;

var elixir = require('laravel-elixir');

/*
 |--------------------------------------------------------------------------
 | Elixir Asset Management
 |--------------------------------------------------------------------------
 |
 | Elixir provides a clean, fluent API for defining some basic Gulp tasks
 | for your Laravel application. By default, we are compiling the Sass
 | file for our application, as well as publishing vendor resources.
 |
 */

elixir(function(mix) {
    // Compile Styles
    mix.sass([
        'main.scss'
        //'../bower_components/sweetalert/dist/sweetalert.css'
    ], 'public/css/app.css');

    // Merge App Internals and Bower Components
    mix.scripts([
        '../bower_components/angular/angular.js',
        '../bower_components/angular-modal-service/dst/angular-modal-service.js',
        '../bower_components/angular-ui-router/release/angular-ui-router.js',
        '../bower_components/ng-remote-validate/release/ngRemoteValidate.0.6.1.js',
        '../bower_components/ngstorage/ngStorage.js',
        '../bower_components/jquery/dist/jquery.js',
        '../bower_components/bootstrap/dist/js/bootstrap.js',
        '../bower_components/underscore/underscore.js',
        '../bower_components/angular-gettext/dist/angular-gettext.js',
        '../bower_components/lodash/dist/lodash.js',
        'ErrorHandler.js',
        'init.js',
        'app.js',
        'config.js',
        'routes.js',
        'i18n.js',
        'controllers',
        'factories',
        'services',
        'providers',
        'directives',
        'filters'
    ], 'public/js/app.js');

    // Version
    mix.version([
        'public/css/app.css',
        'public/js/app.js'
    ]);

    /*
    // Doesn't work well with versioning :(
    mix.browserSync({
        proxy: 'api.aftercare.local'
    });
    */
});
ReberS's avatar

Even if I just execute the styles, this is over 30 seconds right there.

Start time: (2016-04-22 09:01:24 UTC) [treshold=1%,sorted]
 # [order]  module                                                               time  %
  1 [4391]  /var/www/api.aftercare/node_modu..._modules/gulp-cssnano/index.js)    18s  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 46%
  2 [4384]  cssnano (node_modules/cssnano/dist/index.js)                        17.9s  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 45%
  3 [1770]  /var/www/api.aftercare/gulpfile.js (gulpfile.js)                    16.3s  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 41%

The rest goes almost exclusively to browserify, even though I'm not even using it.

It seems to be well knows that cssnano is a terrible choice, which is why it was replaced: https://github.com/laravel/elixir/commit/b9091b4f110ab18e48dcc47e80b460ee75fe5703

However, this does not seem to be in a release yet.

ReberS's avatar

I'm using Vagrant with folder synchronisation. On my host system it works perfectly fine. It can't possibly be that reading and writing a handful of files takes 45 seconds?

martinbean's avatar
Level 80

@ReberS Don't run Gulp from inside your VM. The limited memory and swap is what makes it so slow. I learned that the hard way!

trh88's avatar

Even running Gulp on the host machine is slow:

Saving To...
- public/js/app.js

[16:55:46] 1072676 bytes written (17.00 seconds)
[16:55:46] gulp-notify: [Laravel Elixir] Browserify Compiled!
[16:55:46] Finished 'browserify' after 18 s
[16:55:46] Starting 'copy'...

Please or to participate in this conversation.