Search code examples
laravelgulplaravel-elixir

Elixir and Gulp - Copy and concatenate


How can I copy and concatenate multiple JS files?

I was hoping something like this would work:

    .copy([
            'node_modules/bootstrap-sass/assets/javascripts/bootstrap.js',
            'node_modules/magnific-popup/dist/jquery.magnific-popup.js'
        ],
        'public/js/plugins.js'
    );

But only the later file (magnific-popup.js) is output to plugins.js.


Solution

  • Try using mix.scripts rather than copy:

    elixir(function(mix) {
        mix.scripts(
            // Source files
            [
                'node_modules/bootstrap-sass/assets/javascripts/bootstrap.js',
                'node_modules/magnific-popup/dist/jquery.magnific-popup.js'
            ],
            // Destination
            'public/js/plugins.js'
        );
    });