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

Add exclude option for build.copyPublicDir #14148

Closed
4 tasks done
Plumbiu opened this issue Aug 18, 2023 · 5 comments
Closed
4 tasks done

Add exclude option for build.copyPublicDir #14148

Plumbiu opened this issue Aug 18, 2023 · 5 comments

Comments

@Plumbiu
Copy link
Contributor

Plumbiu commented Aug 18, 2023

Description

When I use vercel to deploy the vite application, I need to write files to the public folder, so I added the .gitkeep file, but vite also uses .gitkeep as a package file.

This problem is because I need to use the web program packaged by vite as a cli tool, but I also want to deploy it to the vercel server for users to view the effect. In order to facilitate API requests, I use the public folder.

Suggested solution

export default defineConfig({
  build: {
    // add exclude option
    copyPublicDir: { exclude: ['.gitkeep'] }
  }
})

Alternative

No response

Additional context

No response

Validations

@Plumbiu Plumbiu changed the title add exclude option for build.copyPublicDir Add exclude option for build.copyPublicDir Aug 18, 2023
@bluwy
Copy link
Member

bluwy commented Aug 18, 2023

I don't think we need a new feature for this since it could be fixed with a post-build step to remove the .gitkeep? We usually try to reduce the API surface area.

But also, (depending on your usecase) could you dynamically create the directory instead of using .gitkeep?

@Plumbiu
Copy link
Contributor Author

Plumbiu commented Aug 19, 2023

The plubic folder will also be used for development, dynamic creation seems a bit cumbersome, remove .gitkeep with a post-build step will be great, thanks!

The. getkeep file is not very large, so preserving it is not a problem, I just hope this option can handle various situations, I brought up a PR and if it's not needed, it can be turned off.

@bluwy
Copy link
Member

bluwy commented Aug 19, 2023

I think we'd want to make public more opinionated, in that it simply copies it entirely to dist. So I think it's best to not add this new option.

It could also be done as a Vite plugin with the generateBundle hook to manually remove the unwanted files too.

I'll see if others have thoughts on this though.

@Plumbiu
Copy link
Contributor Author

Plumbiu commented Aug 24, 2023

Yeah, this application scenario is really limited, so only the .gitkeep file was ignored in the latest PR

@patak-dev
Copy link
Member

Let's close this issue, I also think it is better to avoid adding extra complexity to Vite core if possible. See also #14304 (comment)

@patak-dev patak-dev closed this as not planned Won't fix, can't repro, duplicate, stale Nov 13, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Nov 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants