daisyui / create-daisyui

npm init dasiyui
MIT License
11 stars 2 forks source link

Compatibility with vite #2

Open bailianhua opened 8 months ago

bailianhua commented 8 months ago

The command create the postcss.config.js and tailwind.config.js.

If you try to run it with vite it will cause a fail to load config error (Failed to load PostCSS config)

Vite expect commonjs file extension to be .cjs

For now my workaround is to rename the postcss.config.js and tailwind.config.js to postcss.config.cjs and tailwind.config.cjs

I don't familiar with do a PR on public projects and also didn't quite sure if there're a reason for the file to be .js file.so I'm just gonna file an issue here. if anyone encounter the same problem try rename the file, if author can change to generated file that should fix the compatibility with vite problem

thank you for the tool btw, it's more convenient for me who just start using daisyui.

kuchta commented 7 months ago

@bailianhua I'm using vite and if you have "type": "module" in your package.json it should work with js extensions. I even use .ts extensions for vite.config and tailwind.config. Only postcss.config has to be regular JS and according to postcss/postcss-load-config/pull/249 it should work in the next release of Vite (postcss-load-config is already released with fix, so if you want to play with npm/pnpm overrides you can make it work even now, probably). But that's just for TypeScript setup, if you don't need that, you should be fine with just "type": "module".

saadeghi commented 7 months ago

I'm not sure if using .cjs extension is compatible with all the other bundlers and runtimes.

bailianhua commented 7 months ago

ahhh. got it. Thank you