Replies: 1 comment
-
|
Use npm i rollup-plugin-lit-css @web/dev-server-rollup postcss postcss-load-configweb-dev-server.config.js import rollupLitcss from 'rollup-plugin-lit-css';
import { fromRollup } from '@web/dev-server-rollup';
import postcss from 'postcss';
import postcssConfig from 'postcss-load-config';
const litcss = fromRollup(rollupLitcss);
const config = await postcssConfig();
export default {
...
plugins: [
litcss({ transform: (css, { filePath }) => postcss(config.plugins).process(css, { from: filePath }).css }),
],
mimeTypes: {
'**/*.css': 'js',
},
};postcss.config.js import tailwindcss from 'tailwindcss';
export default {
plugins: [tailwindcss],
};Use import csstxt from './index.css';
@customElement('my-element')
class One extends LitElement {
static styles = [csstxt];
render() {
return html`
<p class="text-red-500 bg-purple-400">Hello from my template.</p>
`;
}
}
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
I want to add
Tailwind(and for that, I guess I have to usePostCSS) to mylitproject, which is usingwds.Details
Hey, I am researching different tools for creating WebComponents, and I came across
litand openWC generator which is perfect for me. But I want to useTailwindCSSfor styles. For that reason, I addedPostCSSlike it is said on the installation page. AddingPostCSSto modern-web seems easy, and I followed the instruction in the docs(first example)So I executed:
And now if I add tailwind styles in my WebComponent doesn't work:
If I run
"start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\""works fine and serves the page, the only thing is that styles are not being generated or inject it into the component.How can I test that
PostCSSis working fine inwds? I guess this problem is related more tolitand its configuration rather thanwdsandPostCSSbut I want to make sure this part is correct.Thanks in advance!!
PD: I also used this tutorial but it's using babel instead of
wdsMy web-dev-server.config.mjs is:
Beta Was this translation helpful? Give feedback.
All reactions