-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Description
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
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.