I am using Laravel 7 to build one of my application. I have the following Javascript dependencies.
- Bootstrap
- Data Tables
- jQuery
- Select 2
- Toastr
- D3
Now I am using the new laravel/ui package and has scaffolded a Bootstrap based application. It uses Laravel Mix and has compiled app.css and app.js file. The app.js has the following code:
require('./bootstrap');
The bootstrap file has following code :
window._ = require('lodash');
try {
window.Popper = require('popper.js').default;
window.$ = window.jQuery = require('jquery');
require('bootstrap');
} catch (e) {}
window.axios = require('axios');
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
I think in this file we need to add the other dependencies. In the documentation also it says to add the Javascript dependencies to here. I have a confusion on how to add DataTables and other above mentioned dependencies to the file. Which package names I need to use in the require ?
Also, most of these packages has their own CSS files too. How can I add the CSS files for all the dependencies in file like the bootstrap.js ? Currently all the CSS files are imported in the app layout blade template. If someone can add a tutorial link , that also will be great.
package.jsonthere are all dependencies that are included inbootstrap.jsfile. So you can install dependencies likeDatatable or select2 etc...using npm and then you can include it inbootstrap.js