_ste_pas_'s avatar

Issue while compiling down js and concatenating

Hey guys,

I am on Laravel 5.4 and desperately trying to compile down resource/assets/js/app.js and then concatenate it with who other js file. Whatever the Laravel Mix configuration, I can't seem to make it work properly. Here it is my code:

mix.js('resources/assets/js/app.js', 'public/js/app.js')
    .combine(['public/js/app.js',
        'resources/assets/js/selectr/selectr.js',
        'resources/assets/js/selectr/selectr-main.js'], 'public/js/app.js')
    .sass('resources/assets/sass/app.sass', 'public/css/app.css')
    .sourceMaps().version();

I can't compile all the files using the js() method because apparently the javascript code in selectr.js breaks. Can you please help?

Thanks.

0 likes
1 reply
ejdelmonico's avatar

Just use the combine method and make you place each file in the correct order. Usually, app.js is last so that the proper methods from other files are available.

Please or to participate in this conversation.