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

[Feature request] Make public url parameter available inside the app #10072

Open
caizixian opened this issue Jan 15, 2025 · 1 comment
Open

Comments

@caizixian
Copy link

caizixian commented Jan 15, 2025

I'd like to revive #5121, and provide more context.

🙋 feature request

Make public url parameter available inside the app.

🤔 Expected Behavior

Expose the argument to parcel --public-url to the user code, such as via process.env.PUBLIC_URL.

😯 Current Behavior

There's apparently no way to retrieve the argument to parcel --public-url programmatically in the user code.

💁 Possible Solution

A workaround is to explicitly specify the public url PUBLIC_URL=<public url> parcel build --public-url <public url>.

🔦 Context

For example, when deploying single page apps built using React Router under a subfolder, it's cleaner to pass the base url to BrowserRouter programmatically. This is useful when, for example, deploying SPA using GitHub pages, when the site would be available under <username>.github.io/<repo name>

💻 Examples

See the above context. webpack seems to have some support https://webpack.js.org/guides/public-path/

@devongovett
Copy link
Member

This will be supported via import.meta.publicUrl in the next release. It was already implemented as part of #10043.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants