Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS Intellisense not working #593

Closed
nazar1ua opened this issue Jan 16, 2023 · 9 comments
Closed

CSS Intellisense not working #593

nazar1ua opened this issue Jan 16, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@nazar1ua
Copy link
Contributor

tailwindlabs/tailwindcss-intellisense#663 (comment)
It is bug on module side

@nazar1ua nazar1ua added the bug Something isn't working label Jan 16, 2023
@nazar1ua
Copy link
Contributor Author

I'm sorry, I looked into module code, and saw that it is problem on @tailwindlabs side with resolveConfig.js file

@nazar1ua nazar1ua closed this as not planned Won't fix, can't repro, duplicate, stale Jan 16, 2023
@nazar1ua
Copy link
Contributor Author

But as a temporary workaround we can do this (at https://github.com/nuxt-modules/tailwindcss/blob/main/src/module.ts#L142-L148):

    const resolveConfig: any = await import('tailwindcss/resolveConfig.js').then(r => r.default || r)
    const resolvedConfig = resolveConfig(tailwindConfig)
    resolvedConfig.plugins = []
    addTemplate({
      filename: 'tailwind.config.cjs',
      getContents: () => `module.exports = ${JSON.stringify(resolvedConfig, null, 2)}`,
      write: true
    })

@nazar1ua nazar1ua reopened this Jan 16, 2023
@nazar1ua
Copy link
Contributor Author

Can I open pr @atinux?

Copy link
Collaborator

atinux commented Jan 18, 2023

Sure thing!

@leo91000
Copy link

For those who can't wait the fix, you can use pnpm patch @nuxtjs/tailwindcss and modify the dist/module.mjs with the @nazar1ua modification

atinux added a commit that referenced this issue Jan 25, 2023
* fix: css intellisense not working (#593)

* chore: add comment

Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
@tkofh
Copy link
Contributor

tkofh commented Feb 16, 2023

The current fix solves the base resolved configuration, but it does not handle plugins from Tailwind Presets.

Reproduction: https://stackblitz.com/edit/nuxt-starter-afebar

I believe we could expand upon the fix like this:

const resolveConfig: any = await import("tailwindcss/resolveConfig.js").then((r) => r.default || r)
const resolvedConfig = resolveConfig(tailwindConfig)
resolvedConfig.plugins = []
for (const preset of resolvedConfig.presets) {
  if(preset.plugins != null) {
    preset.plugins = []
  }
}
addTemplate({
  filename: "tailwind.config.cjs",
  getContents: () => `module.exports = ${JSON.stringify(resolvedConfig, null, 2)}`,
  write: true,
})

Can I open a PR to add this?

@nazar1ua
Copy link
Contributor Author

Yes

@ERPedersen
Copy link

ERPedersen commented Feb 23, 2023

This problem also occurs for me when using purge.options.safelist or just safelist in the root of the tailwind config. If i remove any of these properties, the intellisense starts working again.

Example 1

tailwind.config.js:

export default {
  purge: {
    options: {
      safelist: [
        { pattern: /(bg|text)-./ },
      ],
    },
  },
}

tailwind.config.cjs:

module.exports = {
  'purge': {
    'options': {
      'safelist': [
        {
          'pattern': {},
        },
      ],
    },
  },
  'safelist': [
    {
      'pattern': {},
    },
  ],
};

Example 2 (Tailwind ^3)

tailwind.config.js:

export default {
  safelist: [
    { pattern: /(bg|text)-./ },
  ],
}

tailwind.config.cjs:

module.exports = {
  "safelist": [
    {
      "pattern": {}
    }
  ],
}

@ineshbose
Copy link
Collaborator

Is this still being experienced? This has not been an issue for me recently - I'm not sure what fixed it, maybe the extension was updated in the background, but all intellisense is working flawlessly now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants