To add jQuery to Bootstrap using Vite JS, follow these steps:
npm install bootstrap jquery
index.js
file, import both Bootstrap and jQuery:import 'bootstrap';
import $ from 'jquery';
vite.config.js
in your project root directory and add the following code:export default {
optimizeDeps: {
include: ['jquery'],
},
}
Note: If you are using the Bootstrap JavaScript plugins that rely on jQuery (such as dropdown menus or modals), be sure to include the following JavaScript code at the bottom of your index.html
file:
<script>
$(document).ready(function() {
// Your Bootstrap JavaScript code here
});
</script>
Asked: 2023-07-12 14:51:14 +0000
Seen: 13 times
Last updated: Jul 12 '23