livijn's avatar

Laravel Mix not properly loading jQuery?

Hi, I am trying to load my front end dependencies into my HTML site. For some reason, jQuery is never loaded. My vendor.js looks like this when compiled: http://pastebin.com/jysGvG4w and I am using <script src="{{ mix('/js/vendor.js') }}"></script> in the HTML-page.

The jQuery code is actually there (in the compiled vendor.js) - why is it not loading/working?

webpack.mix.js:

mix
    .js([
        'resources/assets/js/vendor.js'
    ], 'public/js/vendor.js')
    .js([
        'resources/assets/js/app.js'
    ], 'public/js/app.js')
    .sass('resources/assets/sass/app.scss', 'public/css/app.css')
    .version();

vendor.js:

require('jquery');
require('bootstrap-sass');
require('slick-carousel');
require('slidebars');
0 likes
3 replies
jbloomstrom's avatar

I have this in my webpack.mix.js file and it's working.

...
mix.js(...)
  .webpackConfig({
    resolve: {
      modules: [
        'node_modules'
      ],
      alias: {
        'vue$': 'vue/dist/vue.js',
        jquery: 'jquery/src/jquery'
      }
    }
 });
1 like
alenabdula's avatar

Try assigning jQuery

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

Please or to participate in this conversation.