Add jQuery on laravel 5.4 mix

前端 未结 3 821
情书的邮戳
情书的邮戳 2021-02-20 05:00

I\'m already familiar with laravel 5.1 mix (elixir), and recently I decided to test laravel 5.4 mix.

I mixed my libs on vendors files.

mix
.styles([
             


        
相关标签:
3条回答
  • 2021-02-20 05:33

    The solution using laravel mix is force all modules to use the same jquery version: This is my code at top of webpack.mix.js:

    mix.webpackConfig({
        resolve: {
            alias: {
                 'jquery': path.join(__dirname, 'node_modules/jquery/src/jquery')
            }
        }
    });
    
    0 讨论(0)
  • 2021-02-20 05:51

    Just uncomment this line in your assets/js/bootstrap.js file:

    window.$ = window.jQuery = require('jquery');
    

    And make sure to require the bootstrap file in your assets/js/app.js like this:

    require('./bootstrap');
    
    0 讨论(0)
  • 2021-02-20 05:58
    mix.autoload({ 'jquery': ['window.$', 'window.jQuery'] })
    

    I had to add this to my webpack.mix.js

    0 讨论(0)
提交回复
热议问题