serkodev / nuxt-monorepo

Using Nuxt Layers to build a complete monorepo architecture
https://serko.dev/post/nuxt-3-monorepo
85 stars 9 forks source link

TailwindCSS Autocomplete from ui #3

Open Psycarlo opened 1 week ago

Psycarlo commented 1 week ago

Hi serkodev

I enjoyed your article very much.

A problem with TailwindCSS is that we don't get autocomplete: on packages/app/app.vue I don't get autocomplete for the 'bg-ui' class, for example.

*Using vsc and Tailwind CSS IntelliSense extension

Psycarlo commented 1 week ago

My solution was to create yet another package: tailwind-config

package.json

{
  "name": "@nuxt-monorepo/tailwind-config",
  "version": "0.0.0",
  "private": true,
  "devDependencies": {
    "tailwindcss": "^3.4.1"
  }
}

tailwind.config.ts

import { type Config } from 'tailwindcss'

export default <Partial<Config>>{
  theme: {
    extend: {
      colors: {
        brand: {
          primary: '#204B9A',
        }
      },
      fontFamily: {
        brand: ['Inter', 'sans-serif']
      }
    }
  },
  plugins: []
}

I then add this package to ui and app Use the shared config:

tailwind.config.ts

import sharedConfig from "@nuxt-monorepo/tailwind-config/tailwind.config";
import { type Config } from "tailwindcss";

export default <Partial<Config>>{
  presets: [sharedConfig],
};