5

I just did a clean install of laravel. Elixir is not combining my scripts. I am clueless about what's happening. I see the scripts task getting triggered but no files are output in public/js directory.

This is my gulpfile.js:

elixir(function (mix) {
    mix.sass('style.scss')
        .scripts([
            'vendor/jquery.js',
            'vendor/foundation.min.js',
            'script.js'
        ], 'resources/assets/js', 'public/js/app.min.js')
        .scripts([
            'vendor/modernizr.js'
        ], 'resources/assets/js', 'public/js/modernizr.js');
});

It compiles sass properly.

This is the directory structure: https://www.uploady.com/#!/download/221Y0RI_aYe/V7eKiQHIw2gvyXVD

5 Answers 5

7

I found the answer. My second and third argument (input and output directory) to the scripts() function should be interchanged. Seems like this changed in the current version of elixir. Happy coding!

Edit (solution):

elixir(function (mix) {
    mix.sass('style.scss')
        .scripts([
            'vendor/jquery.js',
            'vendor/foundation.min.js',
            'script.js'
        ], 'public/js/app.min.js', 'resources/assets/js')
        .scripts([
            'vendor/modernizr.js'
        ], 'public/js/modernizr.js', 'resources/assets/js');
});
Sign up to request clarification or add additional context in comments.

2 Comments

Add example of working code, so people after you can refer to it please.
elixir.extend('scripts', function(scripts, outputDir, baseDir)
1

I found a similar question here: laracast.com
The problem was that the version of laravel-elixir was not the latest version.
So have a look in your package.json and check which version you are running. Maybe your problem is also the version you use for laravel-elixir.

Comments

0

This worked for me.

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

/*
 |--------------------------------------------------------------------------
 | Elixir Asset Management
 |--------------------------------------------------------------------------
 */

elixir(function(mix) {
    mix.less('app.less')
        .scripts([
            'vendor/underscore.min.js',
            'plugins/dropzone.js',
            'main.js',
            'autocomplete.js',
            'search.js',
            'reviews.js'
        ], 'resources/assets/js', 'public/js/app.js')
        .scripts([
            'admin.js',
            'admin-search.js'
        ], 'resources/assets/js/admin', 'public/js/app-admin.js');
});

Comments

0

Laravel (5.4) is using Laravel Mix now! So basically you have a webpack file now. Take a look at the documentation:

Documentation: https://laravel.com/docs/5.4/mix

Comments

-1

This is worked

elixir(function(mix) {
mix.sass('app.scss')

    mix.styles([
       'bootstrap.css',
        'sb-admin-2.css'

   ],'./public/css/all.css')


       mix.scripts([

           'bootstrap.min.js',
           'sb-admin-2.js'

       ], './public/js/app.js')



 });

Gulp Summary

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.