Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

122
Views
Problems with bundling bootstrap in rollup

I am trying to bundle my stylesheets which should use bootstrap v5. I can bundle my CSS files without a problem but I cannot get bootstrap to work. The bundler runs through, but bootstrap styles are not included.

What I did:

  • I installed bootstrap with npm install bootstrap (https://getbootstrap.com/docs/5.0/getting-started/download/#npm)
  • I included bootstrap into:
    • either my JS file with import 'bootstrap';
    • in my CSS with @import "node_modules/bootstrap/dist/css/bootstrap"; (This is not working because it tells me that my file is not found)

My rollup.config:

import resolve from "@rollup/plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import { terser } from "rollup-plugin-terser";
import postcss from "rollup-plugin-postcss";
import cssnano from "cssnano";

export default [

  {
    input: "project/static/src/inputs/index.js",
    output: [
      {
        format: "esm",
        file: ""project/static/src/outputs/index.min.js",",
      },
    ],
    plugins: [
      postcss({
        extract: true,
        plugins: [cssnano()],
        extensions: [".css"],
      }),
      resolve({
        jsnext: true,
        browser: true,
      }),
      commonjs(),
      terser(),
    ],
  },
];

This config creates a separate CSS file because I set extract = true for the postcss plugin.

Then, in my CSS file:

@import "../modules/css/example.css";
@import "node_modules/bootstrap/dist/css/bootstrap";

.container-example {
  margin-top: -1.5rem;
}

In my JS

import "./example.css";
import 'bootstrap';

//more JS here 

I then run the bundler and it bundles my JS and also my styles. But it does not include any bootstrap styles... I can't seem to figure out why. Maybe because BS is all about SASS? Any ideas? Help is very much appreciated.

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!