Gathering detailed insights and metrics for rollup-plugin-postcss-lit
Gathering detailed insights and metrics for rollup-plugin-postcss-lit
Gathering detailed insights and metrics for rollup-plugin-postcss-lit
Gathering detailed insights and metrics for rollup-plugin-postcss-lit
npm install rollup-plugin-postcss-lit
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
34 Stars
90 Commits
6 Forks
4 Watching
5 Branches
5 Contributors
Updated on 23 Jun 2024
TypeScript (52.12%)
JavaScript (43.93%)
Shell (2.62%)
CSS (1.33%)
Cumulative downloads
Total Downloads
Last day
-12.2%
817
Compared to previous day
Last week
16.5%
5,091
Compared to previous week
Last month
4.7%
19,299
Compared to previous month
Last year
29.9%
233,779
Compared to previous year
2
25
Rollup plugin to load PostCSSed stylesheets in LitElement components
1$ 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.
1// rollup.config.js 2import postcss from 'rollup-plugin-postcss'; 3import postcssLit from 'rollup-plugin-postcss-lit'; 4 5export default { 6 input: 'entry.js', 7 output: { 8 // ... 9 }, 10 plugins: [ 11 postcss({ 12 // ... 13 }), 14 postcssLit(), 15 ], 16}
Add PostCSSed stylesheets to your LitElement components:
1import {LitElement, css} from 'lit'; 2import {customElement} from 'lit/decorators.js'; 3import myStyles from './styles.css'; 4import otherStyles from './other-styles.scss'; 5 6@customElement('my-component') 7export class MyComponent extends LitElement { 8 9 // Add a single style 10 static styles = myStyles; 11 12 // Or more! 13 static styles = [myStyles, otherStyles, css` 14 .foo { 15 color: ${...}; 16 } 17 `]; 18 19 render() { 20 // ... 21 } 22}
1import {LitElement, css} from 'lit'; 2import myStyles from './styles.css'; 3import otherStyles from './other-styles.scss'; 4 5export class MyComponent extends LitElement { 6 7 // Add a single style 8 static get styles() { 9 return myStyles; 10 } 11 12 // Or more! 13 static get styles() { 14 return [myStyles, otherStyles, css` 15 .foo { 16 color: ${...}; 17 } 18 `]; 19 } 20 21 render() { 22 // ... 23 } 24} 25 26customElements.define('my-component', MyComponent);
If you're using the lit-element
package, set the importPackage
option accordingly:
1// rollup.config.js 2import postcss from 'rollup-plugin-postcss'; 3import postcssLit from 'rollup-plugin-postcss-lit'; 4 5export default { 6 input: 'entry.js', 7 output: { 8 // ... 9 }, 10 plugins: [ 11 postcss({ 12 // ... 13 }), 14 postcssLit({ 15 importPackage: 'lit-element', 16 }), 17 ], 18}
This plugin is pre-configured to work with Vite, just add it to plugins
and your styles will be Lit-ified ✨
1// vite.config.js/ts 2import postcssLit from 'rollup-plugin-postcss-lit'; 3 4export default { 5 plugins: [ 6 postcssLit(), 7 ], 8}; 9 10 11// my-component.js/ts 12import myStyles from './styles.css?inline';
⚠️ Use the
?inline
suffix to prevent Vite from adding the styles to the CSS bundle as well
1postcssLit({ 2 3 /** 4 * A glob (or array of globs) of files to include 5 * 6 * @default '**/*.{css,sss,pcss,styl,stylus,sass,scss,less}?(*)' 7 */ 8 include: ..., 9 10 /** 11 * A glob (or array of globs) of files to exclude 12 * 13 * The default filter is used to prevent `<style>` HTML tags from being processed in Vite contexts 14 * @default '**/*\?direct*' 15 */ 16 exclude: ..., 17 18 /** 19 * A string denoting the name of the package from which to import the `css` 20 * template tag function. For lit-element this can be changed to 'lit-element' 21 * 22 * @default 'lit' 23 */ 24 importPackage: ..., 25}),
rollup-plugin-postcss
injects all the imported stylesheets in <head>
by default: this causes an unnecessary style
duplication if you're using the default ShadowDOM
-based style encapsulation in your Lit components. Unless you're using
Light DOM,
consider disabling the inject
option:
1// rollup.config.js 2 3export default { 4 ... 5 plugins: [ 6 postcss({ 7 inject: false, 8 }), 9 postcssLit(), 10 ], 11};
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.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
Found 2/18 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
13 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More