-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Set base with environment variable #7743
Comments
Related #3522 @NicholasLYang we are working to properly support relative base in Vite 3 here: The idea is that you will use Could you check if that PR fixes this issue? The generated HTML and assets can then be deployed with any base. |
I think it is possible to do it like this. // BASE="/foo/" npm run build
import { defineConfig } from 'vite'
export default defineConfig({
base: process.env.BASE
}) |
Oh, I should read more closely next time 🤦🏼 Just for completeness, if you ever want to access an env file in the config, you need to manually loaded. See https://vitejs.dev/config/#environment-variables |
@sapphi-red thanks! That'll work for me. I'll close this issue if there's nothing else to discuss |
Clear and concise description of the problem
I'm running vite as part of bunch of nested npm scripts:
I'd like to pass a base url, but due to a limitation with npm, it's rather hard to pass in arguments to nested scripts. Instead, I'd like the ability to have it passed as an environment variable, i.e.
BASE_URL=/foobarbaz/ npm run build
Suggested solution
Not really sure honestly, would love some guidance.
Alternative
Bug the npm/pnpm people to get better argument propagation. I'll try this too!
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: