PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, November 16, 2022

[FIXED] How to build Bootstrap 4 with jQuery slim and new @popperjs with Laravel-mix?

 November 16, 2022     javascript, laravel, laravel-6, laravel-mix, webpack     No comments   

Issue

The content of webpack.mix.js:

const mix = require('laravel-mix');

mix.js('resources/assets/js/vendor.js', 'public/js');

The content of vendor.js:

window.Popper = require('@popperjs/core').default;

try {
    window.$ = window.jQuery = require('jquery/dist/jquery.slim.js');

    require('bootstrap');
} catch (e) {}

After the build, in the public/js/vendor.js file I can clearly see that @popperjs and jquery.slim.js gets included on top of jquery and old popperjs (they get duplicated).

I know that this happens because node_modules\bootstrap\dist\js\bootstrap.js has require('jquery'), require('popper.js') as dependencies.

How can I build the assets with new @popperjs and jquery.slim.js without the old popperjs and full jquery version?


Solution

It could help you out: https://getbootstrap.com/docs/4.0/getting-started/webpack/#importing-javascript

So you can import plugins individually and use a newer popperjs version. But count on, it might be instable for bootstrap 4 to use a newer popperjs version.

Btw: https://github.com/twbs/bootstrap/issues/29842 chance in bootstrap 5.



Answered By - bornemisza
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing