Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

abhisheknayak_1111's avatar

upgraded from Bootstrap 3 to `"bootstrap": "^5.3.3"`. and removed `bootstrap-sass`

I recently upgraded from Bootstrap 3 to "bootstrap": "^5.3.3". As I understand, bootstrap-sass ("bootstrap-sass": "^3.3.7") is no longer needed in Bootstrap 5, so I removed it and made the following changes:

  1. Replaced:

    @import '~bootstrap-sass/assets/stylesheets/bootstrap';
    

    with:

    @import '~bootstrap-icons/font/bootstrap-icons.css';
    @import '~bootstrap/scss/bootstrap';
    
  2. Replaced:

    require('bootstrap-sass');
    

    with:

    require('bootstrap');
    

However, after removing bootstrap-sass, the UI of DataTables is completely breaking. The layout and styling are not being applied properly.

Has anyone encountered this issue or have suggestions on what I can do to resolve it? Could there be something missing after the removal of bootstrap-sass that's causing this problem?

Thanks!

0 likes
2 replies
RemiM's avatar

I’ve prepared a complete setup for you that should work, as it does on my local environment.

1. Remove existing packages for a fresh install:

npm uninstall bootstrap
npm uninstall bootstrap-sass
npm uninstall sass
npm uninstall datatables.net

2. Install the required packages:

npm install bootstrap@latest jquery@latest datatables.net-bs5@latest

3. Install the specific Sass version to prevent warnings in development:

npm install -D [email protected] --save-exact

4. Your package.json should look like this:

"devDependencies": {
    ...
    "sass": "1.77.6",
    ...
},
"dependencies": {
    "bootstrap": "^5.3.3",
    "datatables.net-bs5": "^2.2.2",
    "jquery": "^3.7.1"
}

5. Create a folder for Sass inside resources and a file named app.scss. Add the following to app.scss:

@use "bootstrap";

6. In your app.js, include the following:

import "./bootstrap";
import "../sass/app.scss";
import * as bootstrap from "bootstrap";

import jQuery from "jquery";
window.$ = jQuery;

import "datatables.net-bs5";

7 - Update your vite.config.js to include the Sass and JS files in the input array:

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';

export default defineConfig({
    plugins: [
        laravel({
            input: ['resources/sass/app.scss', 'resources/js/app.js'],
            refresh: true,
        }),
    ],
});

8. In your Blade view, use the following to initialize the DataTable:

Let me know if you need any further clarification!

martinbean's avatar

However, after removing bootstrap-sass, the UI of DataTables is completely breaking. The layout and styling are not being applied properly.

@abhisheknayak_1111 Breaking how? We can’t see your screen.

Regardless, “DataTables” is a third-party plugin and not something that comes with Bootstrap, so you will need to consult DataTables’ documentation for any notes on using it with different versions of Bootstrap.

Please or to participate in this conversation.