Laravel-mix: Extract method does not respect order of libraries

Created on 9 Apr 2017  路  3Comments  路  Source: JeffreyWay/laravel-mix

  • Laravel Mix Version: 0.10.0
  • Node Version: 6.9.2
  • NPM Version: 4.1.2 (using Yarn 0.20.3)
  • OS: macOS 10.12.3

Description:

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.

Steps To Reproduce:

  1. Create fresh Laravel Mix-based project
  2. yarn add [email protected]
  3. Add the following config to webpack.mix.js:
    mix.extract(['jquery', 'tether', 'bootstrap'], 'dist/vendor.js')
  4. Include dist/vendor.js in your HTML and see an error about Bootstrap requiring jQuery / Tether.

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().

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

All 3 comments

+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 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hasnatbabur picture hasnatbabur  路  3Comments

jpriceonline picture jpriceonline  路  3Comments

pixieaka picture pixieaka  路  3Comments

stefensuhat picture stefensuhat  路  3Comments

terion-name picture terion-name  路  3Comments