As mentioned in #38, the extract
method doesn't respect the order that the libraries are defined in, leading to issues in some situations where the order is important - for example, the Bootstrap 4 alpha (and I believe previous versions as well) depend on both jQuery and Tether, and even if I list them before it, it still complains that they don't exist because it ends up ordered first.
yarn add [email protected]
webpack.mix.js
:
mix.extract(['jquery', 'tether', 'bootstrap'], 'dist/vendor.js')
dist/vendor.js
in your HTML and see an error about Bootstrap requiring jQuery / Tether.+1
If the order is necessary, it's because some libraries are depending upon global variables. This doesn't automatically mesh well with Webpack, so you need to use mix.autoload()
.
mix.autoload({
jquery: ['$', 'jQuery', 'window.jQuery'],
tether: ['Tether', 'window.Tether']
});
Here's more information on autoloading: https://github.com/JeffreyWay/laravel-mix/blob/master/docs/autoloading.md
Fair enough, better for this to be explicit instead of implicit. Thanks for your feedback 馃憤
Most helpful comment
If the order is necessary, it's because some libraries are depending upon global variables. This doesn't automatically mesh well with Webpack, so you need to use
mix.autoload()
.Here's more information on autoloading: https://github.com/JeffreyWay/laravel-mix/blob/master/docs/autoloading.md