How to prevent laravel-mix to include the full jQuery Library
See original GitHub issueI basically used a .js file that I created in a Laravel 5.1 Project and that was now upgrade to Laravel 5.4. In Laravel 5.1 we had elixer and the file was compress as expected.
Now with laravel-mix the fill is also compress and put into public/js/ but the file is much larger because the hole jQuery Library is included.
I want to load jQuery seperate e.g. from a CDN!
mix.js('resources/assets/js/foo.js', 'public/js')
With this lines you can test it:
// resources/assets/js/foo.js
$(document).ready(function(){
$('#foo').removeStyle('bar');
});
this is also do the same (including jQuery):
// resources/assets/js/foo.js
+function ($) {
$(document).ready(function(){
$('#foo').removeStyle('bar');
});
}(jQuery);
laravel-mix: v0.8.1 Node.js: v6.9.5 (latest LTS) yarn: v0.20.3
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
How to prevent laravel-mix to include the full jQuery Library
This snippet specifies that Webpack should prepend var $ = require('jquery') to every location that it encounters either the global $ identifier ...
Read more >Exclude jQuery from Laravel.mix - Laracasts
I'm building a project without the need for jQuery (I'm solving everything with Vue), however the Laravel.mix requires me to add the jquery...
Read more >Laravel Mix always include jQuery - Stack Overflow
I use Laravel 5.6, with Mix. I want to load a plugin which uses jQuery to my project. I created a fileuploader.js file...
Read more >Laravel Mix - Laravel - The PHP Framework For Web Artisans
Laravel Mix, a package developed by Laracasts creator Jeffrey Way, provides a fluent API for defining webpack build steps for your Laravel application...
Read more >Laravel Mix Options
extractVueStyles: Extract . · globalVueStyles: Indicate a file to include in every component styles. · processCssUrls: Process/optimize relative stylesheet url()' ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
docs: https://github.com/JeffreyWay/laravel-mix/blob/master/docs/autoloading.md
@QWp6t I do not have any
bootstrap.js
with thewindow.$ = window.jQuery = require('jquery');
Butmix.autoload({});
in thewebpack.mix.js
file do the trick for me …Would be nice if this finds his way int the Laravel Docs