-1

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.

LW001
  • 2,452
  • 6
  • 27
  • 36
Kira
  • 1,575
  • 4
  • 26
  • 48
  • mix will load those in sequence, can you put app.js at top if you required jquery in app.js? – Hanlin Wang Sep 28 '17 at 16:19
  • Then I get $ is not defined. How do I compress all js files I use into one file? – Kira Sep 29 '17 at 06:06
  • See the more proper resolution at this similar question https://stackoverflow.com/questions/43451509/how-to-install-font-awesome-in-laravel-mix – mike Feb 26 '18 at 21:59

1 Answers1

0

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.

Mark Walet
  • 1,147
  • 10
  • 21
  • So I should use require in my main js file? And lodash is imported because they need it in code. I just want to compress all js files into one file. – Kira Sep 29 '17 at 06:03
  • You didn't include the vanilla jquery in your array. Also, if you just want to concatinate scripts you should use the `scripts()` method instead of the `js()` method. I will update my answer. – Mark Walet Sep 29 '17 at 08:51
  • Actually, later I've added jquery on first place but errors persist. – Kira Sep 30 '17 at 06:47
  • As I mentioned in a comment on the question, this answer to a similar question demonstrates how to properly call the required scripts from `app.js` https://stackoverflow.com/questions/43451509/how-to-install-font-awesome-in-laravel-mix – mike Feb 26 '18 at 22:03