Package Exports
- rollup-plugin-minlinecss
Readme
A very basic Rollup plugin to minify CSS in string templates, for users of inline CSS packages e.g. Goober and Styled JSX.
Usage
Install this package in your project:
# via npm
npm add -D rollup-plugin-minlinecss
# or pnpm
pnpm add -D rollup-plugin-minlinecss
# or yarn
yarn add -D rollup-plugin-minlinecss
Add the plugin to your Rollup config:
// rollup.config.js
import minlinecss from "rollup-plugin-minlinecss";
export default {
plugins: [minlinecss()],
};
Available plugin options are given in plugin options.
The plugin can minify any string templates that contain CSS:
// example.ts
// with selectors
const globalStyles = `
.example {
...
}
...
`;
// without selectors
const Icon = styled("div")`
color: white;
...
`;
// with template substitutions
const Dynamic = styled("div")`
.${class} {
color: ${color};
...
}
...
`;
const Colored = styled("div")`
color: ${color};
...
`;
// the method styled() came from Goober for demonstration
// but the plugin will work without it too
Options
With full TypeScript typing & autocompletion support.
Property | Description |
---|---|
exclude | Files to exclude from minification, for cases that the plugin somehow broke certain code. This is usually not required because the plugin will skip template strings that are not CSS. |
lightningcss | LightningCSS options, for e.g. browser compatibility, do note that CSS nesting is always enabled. |
Have fun with this stupid little plugin.