A tiny wrapper around lightningcss that adds a custom resolver and normalizes CSS module exports.
npm install @plumelo/thunderimport thunder from "@plumelo/thunder";
const result = await thunder({
filename: "src/styles.css",
input: `
.btn { color: red; }
.btn--lg { font-size: 18px; }
`,
});
// result.code — compiled CSS (Buffer)
// result.map — source map
// result.classes — camelCased class name mapping
// e.g. { btn: "btn", btnLg: "btn--lg" }Thunder includes a custom resolver that handles @import resolution using enhanced-resolve:
import thunder, { resolver } from "@plumelo/thunder";
const result = await thunder({
filename: "src/app.css",
input: `@import "theme.css";`,
resolver: resolver({
extensions: [".css", ".scss"],
}),
});Wraps lightningcss.bundleAsync with:
- Automatic targets — defaults to
browserslisttargets if not specified - Custom resolver — uses the built-in resolver by default
- Normalized exports —
result.classesis a camelCased map of CSS module class names
Returns a resolver object for lightningcss's resolver option. Resolves @import specifiers by:
- Treating the specifier as a relative path
- Appending
.cssif the specifier has no extension - Falling back to
enhanced-resolve(node_modules resolution)
| Path | Description |
|---|---|
@plumelo/thunder |
Main API (thunder default export) |
@plumelo/thunder/resolve |
Resolver utility (resolver export) |