32 lines
724 B
TypeScript
32 lines
724 B
TypeScript
import { type BunPlugin } from "bun";
|
|
import dts from "bun-plugin-dts";
|
|
import styleLoader from "bun-style-loader";
|
|
import * as sass from "sass";
|
|
|
|
const style: BunPlugin = {
|
|
name: "Sass Loader",
|
|
setup(build) {
|
|
console.log("Running SASS Plugin...");
|
|
build.onLoad({ filter: /\.scss$/ }, async ({ path }) => {
|
|
const contents = sass.compile(path);
|
|
const css = contents.css;
|
|
|
|
return {
|
|
loader: "file",
|
|
contents: css,
|
|
};
|
|
});
|
|
},
|
|
};
|
|
|
|
const result = await Bun.build({
|
|
outdir: "dist",
|
|
publicPath: "public",
|
|
format: "esm",
|
|
plugins: [style],
|
|
entrypoints: ["./src/components.scss"],
|
|
});
|
|
|
|
if (!result.success) {
|
|
throw new AggregateError(result.logs, "Build failed");
|
|
}
|