-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Support custom mode #12150
Support custom mode #12150
Conversation
🦋 Changeset detectedLatest commit: 7c9b09e 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 |
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.
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.
I really like the fact that we internally create a distinction between "command" and "mode"
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.
Looks great @bluwy ! I'm not sure if it was intentional, but devOutput
was kind of glossed over so I added a sentence to introduce it as a new thing. Some suggestions for your consideration!
Co-authored-by: Sarah Rainsberger <[email protected]>
Looks great! I didn't document |
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.
🥳
Changes
Users can know pass custom
--mode
other thanproduction
anddevelopment
, likestaging
or anything else etc.Within Astro, how do we actually tell in we're in dev or prod state now?
For
astro dev
, it'll always be in the dev state. It's not possible to be in a prod state as it may break existing code, like HMR and stuff (which is also a restriction in Vite)For
astro build
, it'll be prod state by default, unless the user passes--devOutput
which Astro will then switch to a dev state.In other parts of the codebase, there's also the concept of
runtimeMode
which contains this state as either"development"
or"production"
values only.Future coding style
If we want to check the prod or dev state, we should no longer rely on
mode
as that's no longer relevant. We can check via these states instead:viteResolvedConfig.isProduction
runtimeMode
process.env.NODE_ENV === 'production'
import.meta.env.PROD
andimport.meta.env.DEV
Testing
Added a new test to verify that it works.
Docs
withastro/docs#9641