Skip to content

Sourcemap for '...bootstrap.min.css' points to missing source files #10068

@jez9999

Description

@jez9999

Describe the bug

I have Vite configured to include CSS source maps in dev:

export default defineConfig({
    ...
    css: {
        devSourcemap: true
    },
    ...
});

My Vue site's code, in main.js, imports Bootstrap's CSS like this:

import 'bootstrap/dist/css/bootstrap.min.css';

When I load a page on the site, Vite gives me the message:

Sourcemap for "C:/Development/SPA/myApp/node_modules/bootstrap/dist/css/bootstrap.min.css" points to missing source files

React's default Webpack config doesn't seem to have the same problem when I import the Bootstrap minified CSS in the same way. I think it's because the Bootstrap bootstrap.min.css.map file, amongst its various source mappings, includes "dist/css/bootstrap.css". This is apparently supposed to be interpreted relative to the node_modules/bootstrap root, but Vite interprets it relative to bootstrap.min.css, and so it looks for bootstrap/dist/css/dist/css/bootstrap.css and doesn't find it, causing the error.

Reproduction

Configure Vite to include CSS sourcemaps, add Bootstrap to project, import it in Vue file

System Info

System:
    OS: Windows 10 10.0.19042
    CPU: (12) x64 Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
    Memory: 2.06 GB / 15.64 GB
  Binaries:
    Node: 16.15.0 - C:\Program Files\nodejs\node.EXE
    npm: 8.5.5 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.423.0), Chromium (105.0.1343.33)
    Internet Explorer: 11.0.19041.1

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: cssp3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions