简体   繁体   中英

How to add plugins from node_modules to Laravel mix

Here is my code

   mix.js([
        'node_modules/chocolat/dist/js/jquery.chocolat.js',
        'node_modules/textcounter/jquery.textcounter.js',
        'node_modules/foundation-sites/dist/js/foundation.js',
        'node_modules/owl.carousel/dist/owl.carousel.js',
        'resources/assets/js/jquery.fileuploader.min.js',
        'resources/assets/js/app.js',
    ], 'public/js/all.js', './');

And I get error that jQuery is not defined. I have downloaded it, it is 100% there.

In the example provided in the github repo you can see how it normally is included. Check this file: resources\\assets\\js\\bootstrap.js

You should update your webpack file. You didn't include the vanilla jquery in your array. You should do that as the first item in the array. Also, if you just want to concatinate scripts you should use the scripts() method instead of the js() method.

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