A Vite plugin (v1.0.5) that generates CSS sourcemaps during production builds. Unlike Vite's built-in CSS sourcemap support, this plugin provides fine-grained control over sourcemap output location and URL generation, supporting custom extensions like .scss and .less. It hooks into Vite's build pipeline via the `vite:css-post` plugin to emit sourcemap files and add references to CSS output. Requires Vite >=5.0.0 and peer dependencies for Sass processing. Compatible with Vite 5.x and 6.x. Released under MIT license.
npm install vite-plugin-css-sourcemapVerified import paths — ran on the pinned version, not inferred.
Basic setup with Vite config including the plugin and enabling build sourcemaps.
Use only for production builds with 'vite build'.
Add 'build.sourcemap: true' to vite.config.
Install sass or sass-embedded.
Update to v1.0.1 or later.
Update to v1.0.2 or later.
Use 'enabled: true' instead of 'enable: true'.
Use the plugin only in production builds via 'vite build'.
Install sass or sass-embedded: 'npm install sass --save-dev'
Use default import: 'import cssSourcemap from 'vite-plugin-css-sourcemap'' or in CJS: 'const cssSourcemap = require('vite-plugin-css-sourcemap').default'.