gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
33.43k stars 2.53k forks source link

[Custom Components] Provide some configuration for building frontend #7006

Closed Col0ring closed 6 months ago

Col0ring commented 9 months ago

Is your feature request related to a problem? Please describe.
Some javascript libraries need additional processing to be used correctly, could gradio provide some configuration to do this?

Additional context
I found this PR before: https://github.com/gradio-app/gradio/pull/6787, will there be more updates?

pngwn commented 9 months ago

Yep. I'm working on this atm! Should have something shortly!

pngwn commented 9 months ago

@Col0ring Could you tell me more about your use case and what kind of configuration you would need/ be interested in?

Col0ring commented 9 months ago

@Col0ring Could you tell me more about your use case and what kind of configuration you would need/ be interested in?

@pngwn I'm using react to build custom components, and there are two problems: 1.can't use react and jsx at runtime. 2.need to define some global replacements for cjs variables.

I think it will be helpful to allow custom vite options (for server and build mode).

like this:

// gradio.config.ts/js
import react from '@vitejs/plugin-react-swc';

export default defineConfg({
  // `plugins`, `define` and other useful vite options
  viteConfig: {
    plugins:[react()],
    define: {
      // for react
      'process.env.NODE_ENV': JSON.stringify('production'),
    },
  }
})

​