Bun plugin for loading style files
npm install bun-css-loaderBun plugin for loading style files
This plugin loads the contents of all CSS and SCSS files that are imported in JS files and appends them as tags to the DOM's element.
The style tag is accessible either via the default ID css-loader-styles or via a custom ID you can set with the styleId option.
All @import statements inside of the CSS files are processed and resolved.
Now supports PostCSS, adding _TailwindCSS_ support!
Basic:
``js
import cssLoader from 'bun-css-loader';
await Bun.build({
// ...
plugins: [
// ...
cssLoader(),
],
});
`
Style Tag ID:
`js
import cssLoader from 'bun-css-loader';
await Bun.build({
// ...
plugins: [
// ...
cssLoader({ styleId: 'custom-id' }),
],
});
`
TailwindCSS:
`js
// autoprefixer & tailwindcss need to be added as (dev) dependencies to your project
import autoprefixer from 'autoprefixer';
import cssLoader from 'bun-css-loader';
import tailwindcss from 'tailwindcss';
await Bun.build({
// ...
plugins: [
// ...
cssLoader({
postCssPlugins: [tailwindcss(), autoprefixer()],
}),
],
});
``
Distributed under the MIT License. See MIT License for more information.