Registry / devops / rollup-plugin-tailwindcss-lit

rollup-plugin-tailwindcss-lit

JSON →
library1.2.4jsnpmunverified

Rollup plugin that integrates Tailwind CSS with Lit. Stable version 1.2.4. Allows importing Tailwind-generated CSS into Lit static styles arrays, supports @apply directives for inline styles, and works with PostCSS. Unlike generic Tailwind integrations, this plugin is purpose-built for Lit's shadow DOM and static styles system, enabling both external CSS imports and inline Tailwind usage via @apply. Requires Tailwind CSS v3 and Lit. Actively maintained on GitHub.

npm install rollup-plugin-tailwindcss-lit
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-TAIL
R
rollup-plugin-tailwindcss-lit
devopsjavascriptv1.2.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import tailwindcss from 'rollup-plugin-tailwindcss-lit';
const tailwindcss = require('rollup-plugin-tailwindcss-lit');
Plugin is ESM-only; CommonJS require will fail.
default
import styles from 'index.css';
import 'index.css';
You must import the CSS file as a default import to get the CSSResultLike object for Lit static styles.
css
import { css } from 'lit';
Standard Lit import for template literal CSS. Still needed for inline styles alongside the imported styles.

Shows how to configure Rollup with the plugin, alias a CSS file, and use the imported styles in a Lit element.

// rollup.config.js import tailwindcss from 'rollup-plugin-tailwindcss-lit'; import { fileURLToPath } from 'node:url'; import { dirname, resolve } from 'node:path'; import alias from '@rollup/plugin-alias'; const __filename = fileURLToPath(import.meta.url); const cssPath = resolve(dirname(__filename), 'src/index.css'); export default { input: 'src/index.js', output: { dir: 'dist', format: 'es' }, plugins: [ alias({ entries: [{ find: 'index.css', replacement: cssPath }] }), tailwindcss() ] }; // src/index.css @tailwind base; @tailwind components; @tailwind utilities; // src/my-element.js import styles from 'index.css'; class MyElement extends LitElement { static styles = [styles]; render() { return html`<p class="text-blue-500">Hello</p>`; } }
Debug
Known issues
gotchaInline CSS using @apply must include a selector (e.g., ':host') or the styles won't be applied correctly and may cause errors.
fix
Always wrap @apply in a selector: css`:host { @apply text-blue-50; }`
affects: >=1.0
gotchaImporting CSS without a default import (e.g., using side effect import) will not provide the styles object needed for Lit static styles.
fix
Use `import styles from 'index.css'` instead of `import 'index.css'`
affects: >=1.0
gotchaThe plugin expects Tailwind CSS v3; older versions may not work due to changes in the PostCSS plugin API.
fix
Ensure tailwindcss version is ^3.0.0
affects: >=1.0
gotchaUsing the plugin without a PostCSS config (postcss.config.js) will cause Tailwind directives to not be processed.
fix
Create postcss.config.js that includes tailwindcss plugin
affects: >=1.0
Errors
Common errors & fixes
Error: Cannot find module 'index.css'
The import path is not resolved; the plugin needs an alias to map the bare import to an absolute path.
fix
Use @rollup/plugin-alias to alias 'index.css' to the absolute path of your CSS file.
TypeError: styles is not a function
The imported CSS was not transformed into a CSSResultLike object; often due to missing PostCSS or Tailwind configuration.
fix
Ensure postcss.config.js exists and includes tailwindcss plugin.
Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type.
Rollup is trying to parse the CSS output as JavaScript; the plugin isn't transforming the CSS correctly.
fix
Check that the plugin is added to the plugins array and that the CSS file is imported as a default import.
Upgrade
Version history
1.2.4latest on npm
Audit
Dependencies
tailwindcssrequiredPeer dependency; the plugin generates CSS using Tailwind's PostCSS plugin.
postcssrequiredRequired for processing Tailwind directives and PostCSS config.
litrequiredPeer dependency; the output CSS is used with LitElement static styles.
Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
rollup-plugin-tailwindcss-lit — npm install rollup-plugin-tailwindcss-lit · libregistry