rails / tailwindcss-rails

MIT License
1.41k stars 174 forks source link

optional flag to use commonjs configuration when installing #256

Closed emerson-argueta closed 9 months ago

emerson-argueta commented 1 year ago

When installing tailwind using this gem the command is bin/rails tailwindcss:install Using this command adds necessary configuration files to a rails project. One of these configuration files is tailwind.config.js I see there is no option to use a commonjs config file instead. It would be nice to give an optional flag for the install command such as --config-ext=commonjs to add and use the tailwind.config.cjs file instead. The commands then would look like this: bin/rails tailwindcss:install --config-ext=commonjs bin/rails tailwindcss:build --config-ext=commonjs bin/rails tailwindcss:watch --config-ext=commonjs

One of the reasons I raise this issue is because the current tailwind.config.js conflicts when using packages that are ESM modules in my project.

For example my package.json needs to have "type":"module" for vite and svelte to work together in my rails project.

There might be another solution to solve my problem. However, I have forked this repo made some changes and created my own version of this gem which only uses the commonjs configuration and it worked.

I know adding this optional flag would require adding the tailwind.config.cjs in the repo and some changes across different files. I can create a pull request for this, but wanted to know before doing that if this should be implemented.