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 "--viteMode" CLI flag for dev and build command #10871
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 40a60c9 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@bluwy, you are right. I did it just to get this functional parity between dev and build commands. |
If what you say is correct, maybe we should add some documentation (considering that we don't have it) and explain expectations. Like, that it won't work everywhere. |
a987a1f
to
8efc711
Compare
8efc711
to
6be3432
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is blocked because it contains a minor
changeset. A reviewer will merge this at the next release if approved.
@bluwy @ematipico After a more thorough analysis of the code base I decided to use a new flag instead of the existing one. It will be a cleaner and safer solution. It won't affect internal Astro logic (I've checked all possible places). It just passes the flag value to Vite config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick changeset edit from docs, and in case wanted, giving you permission to "sell" this feature a little more! 😄
Changes
What's inside?
This PR adds a new CLI flag
--viteMode
for dev and build commands.The flag value will be passed to the resulting Vite config, allowing us to load different .env.[mode] files. According to Vite documentation, the flag value will also be reflected in
import.meta.env.MODE
.What about the existing
--mode
flag?It works only for the build command and serves a different purpose than the new flag. --mode should have been called --isProd or --isDev because it sets the internal
mode
variable, which is heavily used in the codebase to check for production/development mode. Also, it has never been documented, so it can't be considered a public API.Backward compatibility
As a new feature, it will be a minor change.
Testing
Unit tests were added.
Docs
withastro/docs#8016
/cc @withastro/maintainers-docs