简体   繁体   中英

Laravel 5 Elixir scripts ingredient not working (no file is outputted)

I have a gulpfile for concatenating js files, I have some more code and I want to do this because I'll have different sections on the website and I don't want the user to download css and js he won't use. I currently isolated the code below and the last 'functions' is not outputting anything.

    //works
    mix.scripts(['resources/js/jquery-2.1.1.min.js',
                'resources/js/bootstrap.min.js',
                'resources/js/jquery.maskedinput.min.js'],
              'resources/js/common.js')
    //works
    .scriptsIn('resources/js/user', 'resources/js/user.js')

    //NOPE! No file is created, even if I change the output directory/filename to resources/js or whatever
    .scripts(['resources/js/common.js',
              'resources/js/user.js'],
             'public/js/user.js');

I've tried changing it to use base dir, still nothing:

    .scripts(['common.js',
              'user.js'],
             'public/js/user.js', 'resources/js');

Any ideas?

edit:

Brand new laravel project, new gulp file, scripts ingredient only concatenates one of the two js files (the maskedinput.js one, user.js is completely ignored, even though they are both in the same folder and are the only files there):

elixir(function(mix) {
    mix.scriptsIn('resources/assets/js/user', 'resources/assets/js/user.js');

    mix.scripts(['user.js', 'maskedinput.js'],
       'public/js/user.js', 'resources/assets/js/');

});

Alright, I found a workaround to make it work like I want. I just used what I was using with pure gulp.js, wildcards (docs does not have any info on this):

mix.scripts(['maskedinput.js', 'user/*.js'],
   'public/js/user.js', 'resources/assets/js/');

Now everything is concatenated correctly. Not going to accept this as answer because IMO 'scripts' after 'scriptsIn' still has issues and I'm curious if this is a bug.

I believe you forgot to add .js after changing, so you should try using:

.scripts(['common.js','user.js'],'public/js/user.js', 'resources/js');

EDIT

I've tested your case one more time. It seems at the moment it doesn't work. File that is outputed as a result of any Elixir function ( scriptsIn or script won't be used in another function (for example script in this case). I've played a bit with it and don't see any workaround at this moment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM