laravel-mix: Jscroll extract problem

  • Laravel Mix Version: 0.12.1 (npm list --depth=0)
  • Node Version (node -v): 6.10.3
  • NPM Version (npm -v): 3.10.10
  • OS: Debian

Description:

I want to extract jquery-jscroll into vendor.js and I have this error : jQuery.Deferred exception: $(…).jscroll is not a function [“./resources/assets/js/setup2.js”]/</<@http://172.20.0.3/js/setup2.min.20e168d1323c4340a794.js:12:1 resolve/</mightThrow@http://172.20.0.3/js/vendor.b9ca640f1a8e1fc82b13.js:6051:21 resolve/</process<@http://172.20.0.3/js/vendor.b9ca640f1a8e1fc82b13.js:6119:12 undefined

So jscroll is never imported.

Steps To Reproduce:

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 17 (9 by maintainers)

Most upvoted comments

@gcrispyn Actually I do not know why you want to extract these libraries.

The best way to go around this is to add the packages into the app.js file.

Example: resources/assets/js/app.js

window.Ladda = require('ladda')

With this, Ladda will be inside app.js at compile and you will require 1 less request.

https://laravel.com/docs/5.4/mix#vendor-extraction

The only reason you may want to use extract is to split them up into 3 different js files. This will result in 2 extra http request when the browser is trying to load.

@ruchern I forgot to tell you that i needed to add : <script src="{{ mix('js/jquery.jscroll.js') }}"></script> in my view, and then it works

Many thanks @ruchern !

Ok, it works but I don’t understand. Why couldn’t I use Jscroll as a vendor (vendor.js)? Because it’s a vendor as Jquery or Bootstrap so i want to use it like them.