Skip to content

[Bug]: Official way of Nuxt 3 integration is out of date but here's how to get it working #92

Open
@therealzaybee

Description

@therealzaybee

version

3.0.1

Link to minimal reproduction

NA

Steps to reproduce

NA

What is expected?

NA

What is actually happening?

NA

System Info

No response

Any additional comments?

Official way of Nuxt 3 integration is out of date but here's how to get it working -

  1. Install
npm i -D unplugin-tailwindcss-mangle tailwindcss-patch
  1. Use the vite plugin in nuxt.config.ts
import utwm from 'unplugin-tailwindcss-mangle/vite';

export default defineNuxtConfig({
   .... // Other cofigurations
  vite:{
    plugins: [ process.env.NODE_ENV === "production" ? utwm() : undefined ]
  },
})
  1. create tailwindcss-mangle.config.ts
import { defineConfig } from "tailwindcss-patch";

export default defineConfig({
  patch: {
    output: {
      filename: "./.tw-patch/tw-class-list.json",
      loose: true,
      removeUniversalSelector: true
    },
    tailwindcss: {
      config: "tailwind.config.js",
      cwd: __dirname,
    },
  },
});
  1. Patch tailwind
npx tw-patch install
  1. Extract the classes -
npx tw-patch extract
  1. Build
npm run build

And you are good to go, you can start the preview. I got into few issues after build as the class specificity was messed up because of the class names generated by the plugin. I saw we can specify our custom class name generator functions too, but I didn't play with it much. I removed few classes from the tw-class-list.json which were causing issue for me and it did the job for me.

Thank you @sonofmagic For this awesome engineering.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions