rogden / tailwind-config-viewer

A local UI tool for visualizing your Tailwind CSS configuration file.
1.98k stars 110 forks source link

CLI does not support TypeScript #72

Open iBobik opened 1 year ago

iBobik commented 1 year ago
$ npx tailwind-config-viewer export public
node:internal/modules/cjs/loader:959
  throw err;
  ^
Error: Cannot find module '/tailwind.config.js'
npx tailwind-config-viewer export -c tailwind.config.ts
/Users/Bobik/Sites/vitae-frontend/tailwind.config.ts:1
import { Config } from 'tailwindcss'
^^^^^^

SyntaxError: Cannot use import statement outside a module

When using Taiwind Nuxt module which has viewer embeded TS config works with dev server.

Shmookoff commented 10 months ago

has anyone made progress on this..?

nbrdx commented 8 months ago

I'm also interested in any progress on this feature 👍

rogden commented 8 months ago

Though the importing of Config is only necessary for TS, this seems less like a TS issue and more an ESM issue correct?

urbgimtam commented 8 months ago

Interested in this too. 👀

kedarguy commented 8 months ago

Here is a workaround that worked for me, add the following scripts to package.json

"compile-tw-config": "tsc tailwind.config.ts --outDir dist-tw-config",
"tailwind-config-viewer": "npm run compile-tw-config && tailwind-config-viewer -c dist-tw-config/tailwind.config.js -o -p 3003",
"tailwind-config-export": "npm run compile-tw-config && tailwind-config-viewer -c dist-tw-config/tailwind.config.js export ../design-system"
luixo commented 4 months ago

A very important feature, a pity typescript doesn't work at the moment.

ineshbose commented 4 months ago

When using Tailwind Nuxt module which has viewer embeded TS config works with dev server.

This issue shouldn't persist in the latest versions of the module I hope?

I think ESM support within the module (aside from configs) is #49.

tetarchus commented 2 months ago

Workaround that I've found to work so sharing here (compiling with tsc was not working due to settings elsewhere in a monorepo).

The mkdir call for export was required as the export was failing for me if the directory did not exist - this ensures it does - alternatively just make the directory manually.

Running with npm run tw:inspect then starts the server on port 3000 with no issues.