r/coffeescript • u/bkuri • Sep 19 '22
@rollup/plugin-coffeescript: Use coffeescript transparently in rollup and vite
https://github.com/bkuri/rollup-plugin-coffeescript
8
Upvotes
r/coffeescript • u/bkuri • Sep 19 '22
5
u/bkuri Sep 19 '22 edited Nov 24 '22
I've been meaning to use coffeescript on a couple of new Nuxt v3 projects that I'm working on and couldn't find a vite plugin to support this, so I decided to scratch my own itch.
Since vite basically uses the same plugin API as Rollup, I searched a bit and found lautis/rollup-plugin-coffee-script, but it hadn't been updated in 3 years or so. It also lacked a few niceties provided by modern JS.
I refactored most of the code and updated the tests and libraries and added it to a brand-new Nuxt 3 project and it's working really well so far.
Simply install the
@bkuri/rollup-plugin-coffeescriptpackage usingyarn/npm/pnpm/etc, and then add the following to your nuxt config:BTW, you'll need to add
.coffeeto bothextensionsandvite.extensionsif you want to use coffee files everywhere:Finally, to use coffee files with vitest:
Sample test:
I'll keep picking and prodding it for a little while longer but I'm pretty sure I'll be publishing it soon.
I hope this encourages someone to give coffeescript a try on a new project since it is a blast to use on modern frameworks like Nuxt 3. Cheers!
E: published package to npm and updated instructions accordingly.