An esbuild plugin (v0.1.0) that imports CSS files as minified raw text strings. It allows developers to embed CSS content directly into JavaScript bundles without runtime style injection. The plugin supports optional minification (default true) and works with esbuild versions ^0.14.36, ^0.15.0, or ^0.16.0. This is a niche tool for situations where CSS must be handled as strings, such as dynamic injection or custom style processing, but lacks broader support or active maintenance beyond initial release.
npm install esbuild-plugin-raw-cssNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to configure esbuild with the plugin and verify CSS is imported as raw text.
Always append ?raw to CSS file imports (e.g., import './styles.css?raw').
Pin esbuild to ^0.14.36 || ^0.15.0 || ^0.16.0 or test with newer versions.
Add 'declare module "*.css?raw" { const src: string; export default src; }' to a .d.ts file.Use esbuild's native loader for other CSS preprocessors or extend the plugin.
Ensure rawCssPlugin is included in the plugins array when calling esbuild.build().
Use import rawCssPlugin from 'esbuild-plugin-raw-css' in ESM, or const { default: rawCssPlugin } = await import('esbuild-plugin-raw-css') in CJS.