Removing jquery from Laravel Mix

With Laravel Mix, if you want to use a jquery CDN in the <head> tag, you will get a conflicting version of jquery in your mixed javascript, since Laravel packs in jquery by default (which will override $ in the combined file, but not the blade file that contains the CDN script).

To fix this, remove jquery from the default package.json. In webpack.mix.js append .autoload({})

mix.js('resources/lib/example.js', 'public/js').autoload({});

I didn’t read into why it worked… I’m not too keen on reading the lengthy, complicated guides to webpack.

Update - Laravel 5.5

I recently updated to Laravel 5.5 and it seems this may have been fixed. Now it only works if I remove the .autoload({}).