{"id":15651002,"url":"https://github.com/umbopepato/rollup-plugin-postcss-lit","last_synced_at":"2025-04-13T18:15:22.630Z","repository":{"id":41380826,"uuid":"186592912","full_name":"umbopepato/rollup-plugin-postcss-lit","owner":"umbopepato","description":"Rollup plugin to load PostCSSed stylesheets in LitElement components","archived":false,"fork":false,"pushed_at":"2025-04-12T14:33:34.000Z","size":743,"stargazers_count":34,"open_issues_count":7,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-12T14:43:24.468Z","etag":null,"topics":["css","lit-element","lit-html","postcss","rollup","rollup-plugin"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/umbopepato.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-14T09:45:24.000Z","updated_at":"2025-04-12T13:50:37.000Z","dependencies_parsed_at":"2024-06-18T16:45:51.517Z","dependency_job_id":"86d42f77-8d29-44bd-8dbb-a01f665c15f1","html_url":"https://github.com/umbopepato/rollup-plugin-postcss-lit","commit_stats":{"total_commits":73,"total_committers":8,"mean_commits":9.125,"dds":"0.20547945205479456","last_synced_commit":"e4d31ed5314d160bc6534e5d15cfc7866f12245f"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umbopepato%2Frollup-plugin-postcss-lit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umbopepato%2Frollup-plugin-postcss-lit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umbopepato%2Frollup-plugin-postcss-lit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umbopepato%2Frollup-plugin-postcss-lit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/umbopepato","download_url":"https://codeload.github.com/umbopepato/rollup-plugin-postcss-lit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248585753,"owners_count":21128980,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","lit-element","lit-html","postcss","rollup","rollup-plugin"],"created_at":"2024-10-03T12:36:33.890Z","updated_at":"2025-04-13T18:15:22.622Z","avatar_url":"https://github.com/umbopepato.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rollup plugin postcss lit\n\nRollup plugin to load PostCSSed stylesheets in LitElement components\n\n![Node.js CI](https://github.com/umbopepato/rollup-plugin-postcss-lit/workflows/Node.js%20CI/badge.svg)\n[![Npm release](https://img.shields.io/npm/v/rollup-plugin-postcss-lit.svg)](https://npmjs.org/package/rollup-plugin-postcss-lit)\n[![MIT License](https://img.shields.io/badge/license-MIT-brightgreen)](LICENSE)\n\n## Install\n\n```bash\n$ npm i -D rollup-plugin-postcss-lit\n```\n\n## Usage\n\nAdd `postcssLit` plugin _after_ `postcss`. This wraps PostCSSed styles in Lit's `css`\ntemplate literal tag, so you can import them directly in your components.\n\n```javascript\n// rollup.config.js\nimport postcss from 'rollup-plugin-postcss';\nimport postcssLit from 'rollup-plugin-postcss-lit';\n\nexport default {\n  input: 'entry.js',\n  output: {\n    // ...\n  },\n  plugins: [\n    postcss({\n      // ...\n    }),\n    postcssLit(),\n  ],\n}\n```\n\nAdd PostCSSed stylesheets to your LitElement components:\n\n```typescript\nimport {LitElement, css} from 'lit';\nimport {customElement} from 'lit/decorators.js';\nimport myStyles from './styles.css';\nimport otherStyles from './other-styles.scss';\n\n@customElement('my-component')\nexport class MyComponent extends LitElement {\n\n  // Add a single style\n  static styles = myStyles;\n\n  // Or more!\n  static styles = [myStyles, otherStyles, css`\n    .foo {\n      color: ${...};\n    }\n  `];\n\n  render() {\n    // ...\n  }\n}\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eJS version\u003c/summary\u003e\n\n```javascript\nimport {LitElement, css} from 'lit';\nimport myStyles from './styles.css';\nimport otherStyles from './other-styles.scss';\n\nexport class MyComponent extends LitElement {\n\n  // Add a single style\n  static get styles() {\n    return myStyles;\n  }\n\n  // Or more!\n  static get styles() {\n    return [myStyles, otherStyles, css`\n      .foo {\n        color: ${...};\n      }\n    `];\n  }\n\n  render() {\n    // ...\n  }\n}\n\ncustomElements.define('my-component', MyComponent);\n```\n\n\u003c/details\u003e\n\n### Usage with lit-element\n\nIf you're using the `lit-element` package, set the [`importPackage` option](#options) accordingly:\n\n```javascript\n// rollup.config.js\nimport postcss from 'rollup-plugin-postcss';\nimport postcssLit from 'rollup-plugin-postcss-lit';\n\nexport default {\n  input: 'entry.js',\n  output: {\n    // ...\n  },\n  plugins: [\n    postcss({\n      // ...\n    }),\n    postcssLit({\n      importPackage: 'lit-element',\n    }),\n  ],\n}\n```\n\n### Usage with Vite\n\nThis plugin is pre-configured to work with Vite, just add it to `plugins` and your styles will be Lit-ified ✨\n\n```javascript\n// vite.config.js/ts\nimport postcssLit from 'rollup-plugin-postcss-lit';\n\nexport default {\n  plugins: [\n    postcssLit(),\n  ],\n};\n\n\n// my-component.js/ts\nimport myStyles from './styles.css?inline';\n```\n\n\u003e ⚠️ Use the `?inline` suffix to prevent Vite from adding the styles to the CSS bundle as well\n\n## Options\n\n```javascript\npostcssLit({\n\n  /**\n   * A glob (or array of globs) of files to include\n   *\n   * @default '**‎/*.{css,sss,pcss,styl,stylus,sass,scss,less}?(*)'\n   */\n  include: ...,\n\n  /**\n   * A glob (or array of globs) of files to exclude\n   *\n   * The default filter is used to prevent `\u003cstyle\u003e` HTML tags from being processed in Vite contexts \n   * @default '**‎/*?direct*'\n   */\n  exclude: ...,\n\n  /**\n   * A string denoting the name of the package from which to import the `css`\n   * template tag function. For lit-element this can be changed to 'lit-element'\n   * \n   * @default 'lit'\n   */\n  importPackage: ...,\n}),\n```\n\n## PostCSS plugin setup\n\n`rollup-plugin-postcss` injects all the imported stylesheets in `\u003chead\u003e` by default: this causes an unnecessary style\nduplication if you're using the default [ShadowDOM](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_shadow_DOM)\n-based style encapsulation in your Lit components. Unless you're using\n[Light DOM](https://lit.dev/docs/components/shadow-dom/#implementing-createrenderroot),\nconsider disabling the `inject` option:\n\n```javascript\n// rollup.config.js\n\nexport default {\n  ...\n  plugins: [\n    postcss({\n      inject: false,\n    }),\n    postcssLit(),\n  ],\n};\n```\n\n## When should I use it?\n\nThis plugin is meant to be used with [`rollup-plugin-postcss`](https://github.com/egoist/rollup-plugin-postcss).\nIf you only need to load plain css files in your LitElement components,\nconsider using [`rollup-plugin-lit-css`](https://github.com/bennypowers/rollup-plugin-lit-css).\n\n### Contributors\n\n\u003ca href=\"https://github.com/umbopepato/rollup-plugin-postcss-lit/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contributors-img.web.app/image?repo=umbopepato/rollup-plugin-postcss-lit\" height=\"40\"/\u003e\n\u003c/a\u003e\n\n\n### License\n\nThis project is licensed under the MIT License, see [LICENSE](./LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumbopepato%2Frollup-plugin-postcss-lit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fumbopepato%2Frollup-plugin-postcss-lit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumbopepato%2Frollup-plugin-postcss-lit/lists"}