vite-plugin-civet icon indicating copy to clipboard operation
vite-plugin-civet copied to clipboard

support for vue?

Open webdevcody opened this issue 2 years ago • 3 comments

I was trying to use lang='civet' using this vite plugin, but it doesn't seem to work. Any clue if that's something easy to add in?

webdevcody avatar Mar 01 '23 06:03 webdevcody

The following code transforms <script src="foo.civet"></script> content:

https://github.com/lorefnon/vite-plugin-civet/blob/6e030114d33d53519eee2198ad8891c3a4747279/src/index.ts#L64-L73

I'm guessing you want the ability to write

<script lang="civet">
console.log "hello world"
</script>

? That shouldn't be difficult to add to this function. I'm less certain on whether transformIndexHtml would be enough for Vue though; we might need to specially handle .vue files?

edemaine avatar Mar 12 '23 18:03 edemaine

To support .vue files we'd likely need to add an integration with https://www.npmjs.com/package/@vue/compiler-sfc, but unfortunately I don't have time to implement this. Happy to merge this if someone is willing to contribute.

Alternatively, you can use the jsx support in vue which is more concise & pleasant with civet instead of sfcs.

lorefnon avatar Mar 13 '23 07:03 lorefnon

To support .vue files we'd likely need to add an integration with https://www.npmjs.com/package/@vue/compiler-sfc, but unfortunately I don't have time to implement this. Happy to merge this if someone is willing to contribute.

Alternatively, you can use the jsx support in vue which is more concise & pleasant with civet instead of sfcs.

I immediately thought about @vue/compiler-sfc when I saw the docs of Civet & Vite plugin but didn't understand it. But I recently played with Vue Macros Full SFC and they convert TSX to valid Vue components, so I thought to myself "it shouldn't be hard".

So in the meantime, I will create a script that converts all the .civet files containing default-exported Composition API objects into .ts, and then using them with . 😁 That's all I can think of!

(I don't see how to use TSX with Civet and Vite plugin, if anyone have a guide, I will appreciate it a lot).

angelhdzmultimedia avatar Mar 20 '23 21:03 angelhdzmultimedia