Tailwindcss workflow with nuxt.js #24
Comments
I just made an official example to use Tailwindcss with Nuxt.js, source code: https://github.com/nuxt/nuxt.js/tree/dev/examples/tailwindcss Demo: https://tailwindcss.nuxtjs.org/ Enjoy 🎉 |
Hi @Atinux Thanks for your example. It doesn't cover the composability use case for Tailwind, though. For example, if I do the following:
I get an error that Any thoughts? Cheers. |
@djeglin I'm not sure anyone's got the magic potion for using See also: tailwindcss/tailwindcss#150 and tailwindcss/tailwindcss#1 Kind of a bummer. Right now I'm just avoiding the |
To get |
Interesting. I wonder if it’s possible to somehow set that as a global include…? I might look into that.
Cheers.
On Thu, Nov 9, 2017 at 19:50, Collin Henderson <notifications@github.com> wrote:
To get @apply rules to work in your style block you have to include @tailwind utilities; at the top. Of course this will duplicate the Tailwind code for each component that uses it, but you can mitigate this using https://github.com/ChristianMurphy/postcss-combine-duplicated-selectors [https://github.com/ChristianMurphy/postcss-combine-duplicated-selectors] which will merge any duplicate selectors it finds.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub [#24 (comment)] , or mute the thread [https://github.com/notifications/unsubscribe-auth/AANccNkImjO-_JINh8lhOT2GeC_i6jnEks5s01eZgaJpZM4QQtr7] .
|
Anybody has any idea how to do this properly? Using |
Use PurgeCSS.
…Sent from my iPhone
On Nov 28, 2017, at 10:45 PM, pxwee5 ***@***.***> wrote:
Anybody has any idea how to do this properly? Using @apply in Nuxt's SFC without the bloat.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Purge CSS did manage to reduce most of the TW utilities in the |
You should use a Webpack plugin to extract your CSS into a file at build time. Nuxt might already do this with production builds, I'm not too sure.
…Sent from my iPhone
On Nov 29, 2017, at 1:42 AM, pxwee5 ***@***.***> wrote:
Purge CSS did manage to reduce most of the TW utilities in the main.css file. However, they are all included in the code splitted .js files.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
It's the bold part that gets doesn't get purged by PurgeCSS. |
In next release of Nuxt, you will be able to say to extract all chunks into the common.css file, see nuxt/nuxt#2081 |
True you're correct. However, that means you lose the ability to load css on demand. When you have hundreds of components these styles add up. The closest thing I found is using Until there's a true support for TW in Nuxt. |
Hey @Atinux, I was just playing with your Nuxt.js tailwind example It seems to include both Tailwind's But then Nuxt adds any Wouldn't it be better if Tailwind's utility classes were imported after these component styles? Thisway it wouldn't be necessary to move all component styles into the middle of Apologies if I'm completely off base here. Just a thought. |
Hi @01ivr3 Actually there is not better solution at the moment but we are trying to find a way to make Tailwind works nicely with Vue and so with Nuxt.js |
@Atinux thanks for the reply! stoked to hear you guys are working on that ;) |
For Nuxt2 project:
|
@johnyluyte the link you provided in step 4 does not show postcss.config.js code |
@johnyluyte, does this work with inline styles? |
@johnyluyte A small suggestion: your suggestion does not handle the tailwind classes that use spacial characters like
|
@MichMich You can now enable an option for shadowLookup, documented here: https://github.com/tailwindcss/tailwindcss/releases#allow-applying-classes-that-arent-defined-but-would-be-generated This handles this use case without the need to import the main Tailwind css file in each component, and without the need to run purgeCSS. I believe this negates the need for this issue to be open any longer. Cheers. |
@djeglin Not sure if I understand correctly. But it seems that has a different purpose. Without the above config the CSS will not be purged. |
@MichMich The conversation here was about allowing Tailwind classes to be This allows for the following in a Vue component file:
... but the only CSS that will actually be output will be the those selectors and the result of those Does that make sense, and match your use case? |
@djeglin I was looking for the correct way to incorporate PurgeCSS and stumbled upon @johnyluyte's comment. This solved the issue for me with one minor issue as discussed in my reply. I posted my solution for anyone looking for the same info. It might be a tiny bit offtopic, but since I found my answer here I though it was good to add a small piece of information for others that are looking for the same info. |
@MichMich Fair enough, that makes sense. FWIW, the shadowLookup method will result in significantly faster builds than using purgeCSS, but its good to mark the information down for others. |
Hi Guys I've been trying to make this work with nuxt.js smoothly but I am not successful.
Is it possible to implement this together with nuxt without using gulp only webpack?
The text was updated successfully, but these errors were encountered: