@lass-lang/bun-plugin-lass
v0.0.1
Published
Bun plugin for Lass language
Downloads
82
Maintainers
Readme
@lass-lang/bun-plugin-lass
Bun plugin for processing .lass files. Transforms Lass source to CSS via @lass-lang/core.
Installation
bun add @lass-lang/bun-plugin-lass --devUsage
With Bun.build()
import lass from "@lass-lang/bun-plugin-lass";
await Bun.build({
entrypoints: ["./src/index.ts"],
outdir: "./dist",
plugins: [lass()],
});With bunfig.toml (preload)
For automatic .lass support without explicit plugin configuration:
# bunfig.toml
preload = ["@lass-lang/bun-plugin-lass/preload"]Then import .lass files directly:
import "./styles.lass";CSS Modules
CSS Modules work with .module.lass files:
import styles from "./component.module.lass";
element.className = styles.container;For TypeScript, add declarations:
// lass.d.ts
declare module "*.lass";
declare module "*.module.lass" {
const classes: { readonly [key: string]: string };
export default classes;
}Options
lass({
verbose: true, // Enable logging (default: false)
});Limitations
- No HMR: Bun's plugin API doesn't support Hot Module Replacement.
For development with HMR, use Vite with
@lass-lang/vite-plugin-lass.
How It Works
- Plugin intercepts
.lassfile imports viaonResolve/onLoad - Transpiles Lass source to JS module via
@lass-lang/core - Executes JS to extract CSS string
- Returns CSS to Bun's bundler with
loader: "css" - For
.module.lass: resolves to virtual.lass.module.csspath so Bun applies CSS Modules scoping
Peer Dependencies
bun>=1.0.0
License
MIT
