Git Product home page Git Product logo

Comments (7)

bluwy avatar bluwy commented on June 12, 2024 2

I'm not familiar with React (nor the vite plugin) so I can't say for sure if there are caveats to this. @aleclarson might know more about it.

from vite-plugin-react.

ArnaudBarre avatar ArnaudBarre commented on June 12, 2024 1

Hi!
Yes that's a limitation of the current API. Making this change non breaking would make the API unusable so I plan to change this in the next major with #53, hopefully in less than one month

from vite-plugin-react.

Niputi avatar Niputi commented on June 12, 2024

please give more details.
what exactly are you trying to do and how do you expect it to work

from vite-plugin-react.

LaamGinghong avatar LaamGinghong commented on June 12, 2024

@Niputi
I wrote a Vite plugin to transform markdown to React component. The output of the plugin looks something like this:

export default () => <div> {/* The transformed code */}</div>

However, @vitejs/plugin-react could not accept a .md file and I had to use babel to transform the jsx to js.

This is my current configuration file:

plugins: [
  vitePluginDocs(), // my markdown transform plugin
  babel({
    extensions: ['.md'],
    configFile: false,
    presets: [['@babel/preset-react', { runtime: 'automatic' }]],
    babelHelpers: 'bundled'
  })
  viteReact()
]

I want the @vitejs/plugin-react to accept an extra parameter to accept more file's format like this:

plugins: [
  vitePluginDocs(), // my markdown transform plugin
  viteReact({ extensions: ['.tsx', '.md'], })
]

So I can remove the babel from my config.

from vite-plugin-react.

LaamGinghong avatar LaamGinghong commented on June 12, 2024

By reading the plugin's code, I found that the plugin will only convert mjs | js | jsx | ts | tsx file

from vite-plugin-react.

bluwy avatar bluwy commented on June 12, 2024

vite-plugin-svelte has a similar feature too that allows specifying the extensions. Probably worth nothing a caveat though: sveltejs/vite-plugin-svelte#60

from vite-plugin-react.

LaamGinghong avatar LaamGinghong commented on June 12, 2024

@bluwy I think it's a nice feature, so what do you think?

from vite-plugin-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.