
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
rollup-plugin-postcss-lit
Advanced tools
Rollup plugin to load PostCSSed stylesheets in LitElement components
Rollup plugin to load PostCSSed stylesheets in LitElement components
$ npm i -D rollup-plugin-postcss-lit
Add postcssLit
plugin after postcss
. This wraps PostCSSed styles in Lit's css
template literal tag, so you can import them directly in your components.
// rollup.config.js
import postcss from 'rollup-plugin-postcss';
import postcssLit from 'rollup-plugin-postcss-lit';
export default {
input: 'entry.js',
output: {
// ...
},
plugins: [
postcss({
// ...
}),
postcssLit(),
],
}
Add PostCSSed stylesheets to your LitElement components:
import {customElement, LitElement, css} from 'lit-element';
import myStyles from './styles.css';
import otherStyles from './other-styles.scss';
@customElement('my-component')
export class MyComponent extends LitElement {
// Add a single style
static styles = myStyles;
// Or more!
static styles = [myStyles, otherStyles, css`
.foo {
color: ${...};
}
`];
render() {
// ...
}
}
import {LitElement, css} from 'lit-element';
import myStyles from './styles.css';
import otherStyles from './other-styles.scss';
export class MyComponent extends LitElement {
// Add a single style
static get styles() {
return myStyles;
}
// Or more!
static get styles() {
return [myStyles, otherStyles, css`
.foo {
color: ${...};
}
`];
}
render() {
// ...
}
}
customElements.define('my-component', MyComponent);
If you're using Lit 2, set the importPackage
option accordingly:
// rollup.config.js
import postcss from 'rollup-plugin-postcss';
import postcssLit from 'rollup-plugin-postcss-lit';
export default {
input: 'entry.js',
output: {
// ...
},
plugins: [
postcss({
// ...
}),
postcssLit({
importPackage: 'lit',
}),
],
}
This plugin is pre-configured to work with Vite, just add it to plugins
and your styles will be Lit-ified ✨
// vite.config.js/ts
import postcssLit from 'rollup-plugin-postcss-lit';
export default {
plugins: [
postcssLit(),
],
};
postcssLit({
// A glob (or array of globs) of files to include.
// Default: **/*.{css,sss,pcss,styl,stylus,sass,scss,less}
include: ...,
// A glob (or array of globs) of files to exclude.
// Default: null
exclude: ...,
// A string denoting the name of the package from which to import the `css`
// template tag function. For Lit 2 this can be changed to 'lit'
// Default: 'lit-element'
importPackage: '...',
}),
This plugin is meant to be used with rollup-plugin-postcss
.
If you only need to load plain css files in your LitElement components,
consider using rollup-plugin-lit-css
.
This project is licensed under the MIT License, see LICENSE for details.
FAQs
Rollup plugin to load PostCSSed stylesheets in LitElement components
The npm package rollup-plugin-postcss-lit receives a total of 11,100 weekly downloads. As such, rollup-plugin-postcss-lit popularity was classified as popular.
We found that rollup-plugin-postcss-lit demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.