vuejs / vetur

Vue tooling for VS Code.
https://vuejs.github.io/vetur/
MIT License
5.75k stars 594 forks source link

how to format lang="jsx" in .vue file #2781

Open 604587986 opened 3 years ago

604587986 commented 3 years ago

Feature Request

<script lang="jsx">

@vitejs/plugin-vue-jsx need this way of writing, but vetur cannot format jsx or tsx

yoyo930021 commented 3 years ago

We support tsx when <script lang="tsx">

604587986 commented 3 years ago

I still hope it supports formatting jsx lang

XibeiGitHub commented 10 months ago

You can use the [vite-plugin-lang-jsx] plugin,Configure invite.config.js, like :

//vite.config.js
import { defineConfig } from 'vite'
import vue2 from "@vitejs/plugin-vue2";
import vueJsx from "@vitejs/plugin-vue2-jsx";
import langJsx from "vite-plugin-lang-jsx";

export default defineConfig({
  plugins: [
    langJsx(), //langJsx must precede vue
    vue2(),
    vueJsx()
  ]
})

This way you don’t have to write lang="jsx" in <script></script>,Refer to my Demo[vite-vue2-jsx].