Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow custom component authors to provide custom vite plugins and svelte preprocessors #6787

Merged
merged 9 commits into from
Apr 25, 2024

Conversation

pngwn
Copy link
Member

@pngwn pngwn commented Dec 14, 2023

Description

Please include a concise summary, in clear English, of the changes in this pull request. If it closes an issue, please mention it here.

Closes #8044. Closes #7927. Closes #7006.

🎯 PRs Should Target Issues

Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.

Not adhering to this guideline will result in the PR being closed.

Tests

  1. PRs will only be merged if tests pass on CI. To run the tests locally, please set up your Gradio environment locally and run the tests: bash scripts/run_all_tests.sh

  2. You may need to run the linters: bash scripts/format_backend.sh and bash scripts/format_frontend.sh

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Dec 14, 2023

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
Storybook ready! Storybook preview
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-builds.s3.amazonaws.com/4aea4918958e72f36eec9b3c7de86f34d9aa6054/gradio-4.27.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@4aea4918958e72f36eec9b3c7de86f34d9aa6054#subdirectory=client/python"

@pngwn pngwn changed the title allow users to provide custom vite plugins and svelte preprocessors allow custom component authors to provide custom vite plugins and svelte preprocessors Dec 14, 2023
@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Dec 14, 2023

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/preview minor
gradio minor
gradio_test minor
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

allow custom component authors to provide custom vite plugins and svelte preprocessors

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@pngwn pngwn marked this pull request as draft December 14, 2023 23:01
@pngwn
Copy link
Member Author

pngwn commented Dec 15, 2023

We need to do something else.

@pngwn pngwn closed this Dec 15, 2023
@pngwn pngwn reopened this Apr 24, 2024
@pngwn pngwn marked this pull request as ready for review April 24, 2024 13:50
@pngwn
Copy link
Member Author

pngwn commented Apr 24, 2024

Important

Outdated! Updated instructions.

To test this:

run pnpm build from the root.

Copy paste this code in to the js/preview/test/test/frontend/gradio.config.js:

import tailwindcss from "@tailwindcss/vite";

export default {
	plugins: [tailwindcss()]
};

Add this file in the frontend dir:

main.css:

@import "tailwindcss";

Add this code to Index.svelte:

import './main.css';

Run this command in the frontend dir:

pnpm add -D tailwindcss@next @tailwindcss/vite@next

cd back into test/test and run:

gradio cc install --npm-install="pnpm i"
gradio cc dev

@pngwn
Copy link
Member Author

pngwn commented Apr 24, 2024

tbh i'll just push these changes

@pngwn
Copy link
Member Author

pngwn commented Apr 24, 2024

New instructions:

pnpm i
ppm build
cd js/preview/frontend/test/test
gradio cc install --npm-install="pnpm i"
gradio cc dev

then visit the URL shown in the console.

@freddyaboulton
Copy link
Collaborator

Awesome, I copied some random code from the internet and it just works

image

FYI: going to start accepting payments in my gradio apps 😂

Copy link
Collaborator

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice @pngwn ! Let's please write some docs for this in the frontend guide: https://www.gradio.app/guides/frontend

I still think we should provide an empty gradio.config.js file in the create command so that users know about it without having to use the guides. Maybe we include some commented out code like "to add tailwind, add the following"

@pngwn
Copy link
Member Author

pngwn commented Apr 24, 2024

Good idea. Will update.

@pngwn
Copy link
Member Author

pngwn commented Apr 24, 2024

@freddyaboulton I have done the following:


The `gradio.config.js` file should be placed in the root of your component's `frontend` directory. A default config file is created for you when you create a new component. But you can also create your own config file and use it to customize your component's build process.

```typescript
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to close this codeblock

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah nice catch.

Copy link
Collaborator

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs changes look good to me @pngwn !

@pngwn pngwn merged commit 15a7106 into main Apr 25, 2024
7 of 8 checks passed
@pngwn pngwn deleted the cc-plugins branch April 25, 2024 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants