bun-css-loader
v1.4.2
Published
Bun plugin for loading style files
Downloads
4,583
Maintainers
Readme
bun i -D bun-css-loader
About
This plugin loads the contents of all CSS and SCSS files that are imported in JS files and appends them as <style>
tags to the DOM's <head>
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!
How-To
Basic:
import cssLoader from 'bun-css-loader';
await Bun.build({
// ...
plugins: [
// ...
cssLoader(),
],
});
Style Tag ID:
import cssLoader from 'bun-css-loader';
await Bun.build({
// ...
plugins: [
// ...
cssLoader({ styleId: 'custom-id' }),
],
});
TailwindCSS:
// 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()],
}),
],
});
License
Distributed under the MIT License. See MIT License for more information.