Registry / web-framework / vite-plugin-css-sourcemap

vite-plugin-css-sourcemap

JSON →
library1.0.5jsnpmunverified

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-sourcemap
INSTALL
IMPORT
SIG · VITE-PLUGIN-CSS-SO
V
vite-plugin-css-sourcemap
web-frameworkjavascriptv1.0.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import cssSourcemap from 'vite-plugin-css-sourcemap'
import { cssSourcemap } from 'vite-plugin-css-sourcemap'
The plugin is exported as a default export. Named import will fail.
CjsRequire
const cssSourcemap = require('vite-plugin-css-sourcemap').default
const cssSourcemap = require('vite-plugin-css-sourcemap')
In CommonJS, the default export is under .default. Direct require() gives an object, not the function.
Plugin type
import type { Plugin } from 'vite'
import { Plugin } from 'vite-plugin-css-sourcemap'
Vite plugins have their own Plugin type; the package does not export a custom type.

Basic setup with Vite config including the plugin and enabling build sourcemaps.

// vite.config.ts import { defineConfig } from 'vite'; import cssSourcemap from 'vite-plugin-css-sourcemap'; export default defineConfig({ plugins: [cssSourcemap()], build: { cssCodeSplit: true, sourcemap: true, }, }); // Ensure at least one CSS file is imported in your project // Run 'vite build' to produce CSS with sourcemap references
Debug
Known issues
breakingPlugin only works during build; no effect in dev mode.
fix
Use only for production builds with 'vite build'.
affects: >=1.0.0
gotchaMust set 'build.sourcemap' to true or 'hidden' in Vite config for sourcemaps to be generated.
fix
Add 'build.sourcemap: true' to vite.config.
affects: >=1.0.0
gotchaFor .scss files, either 'sass' or 'sass-embedded' must be installed as a dev dependency.
fix
Install sass or sass-embedded.
affects: >=1.0.0
breakingIn v1.0.0, entry with no hash could produce null sourcemap; fixed in v1.0.1.
fix
Update to v1.0.1 or later.
affects: <=1.0.0
breakingIn v1.0.2, path argument must be a string; earlier versions crashed on non-string paths.
fix
Update to v1.0.2 or later.
affects: <=1.0.1
deprecatedThe 'enable' option is deprecated; use 'enabled' instead (typo fix).
fix
Use 'enabled: true' instead of 'enable: true'.
affects: >=1.0.0
Errors
Common errors & fixes
Error: The plugin is not working in dev mode
Plugin is designed only for build phase.
fix
Use the plugin only in production builds via 'vite build'.
Error: Cannot find module 'sass'
Missing peer dependency for scss processing.
fix
Install sass or sass-embedded: 'npm install sass --save-dev'
TypeError: cssSourcemap is not a function
Incorrect import or require pattern.
fix
Use default import: 'import cssSourcemap from 'vite-plugin-css-sourcemap'' or in CJS: 'const cssSourcemap = require('vite-plugin-css-sourcemap').default'.
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies
viterequiredCore build tool, required as peer dependency.
sassoptionalRequired for .scss file processing; can be replaced with sass-embedded.
sass-embeddedoptionalAlternative Sass engine for .scss files.
Agent activity
5 hits · last 30 days
node
4
OpenAI (training)
1
Resources
vite-plugin-css-sourcemap — npm install vite-plugin-css-sourcemap · libregistry