Move to a singular flag
This might not be enough if we also want to cater for development desktop builds, but let's start with this and add them back later if needed.
This commit is contained in:
parent
c921399540
commit
3ad29a504c
1 changed files with 9 additions and 43 deletions
|
@ -73,50 +73,16 @@ export const getFamilyPortalURL = () => {
|
|||
};
|
||||
|
||||
/**
|
||||
* A build is considered as a development build if one of the following holds:
|
||||
* A build is considered as a development build if the NODE_ENV environment
|
||||
* variable is set to 'development'.
|
||||
*
|
||||
* 1. The NODE_ENV environment variable is set to 'development'. This
|
||||
* automatically happens when we run `yarn dev:foo`, but we can also
|
||||
* explictly set this to development before invoking the build. From the
|
||||
* Next.js docs:
|
||||
* This automatically happens when we run `yarn dev:foo`, but we can also
|
||||
* explictly set it to development before invoking the build. From Next.js docs:
|
||||
*
|
||||
* > If the environment variable NODE_ENV is unassigned, Next.js
|
||||
* > automatically assigns development when running the `next dev` command,
|
||||
* > or production for all other commands.
|
||||
*
|
||||
* 2. Sometimes we're building for a remote deployment, but we want the deployed
|
||||
site to behave as a development build. For example, when deploying the
|
||||
main branch to `testing.ente.io`. In these cases, since the build was done
|
||||
using `yarn export` (which in turn invokes `next build`), the NODE_ENV
|
||||
will not get set to 'development'. To handle such cases, we introduce
|
||||
another variable, NEXT_PUBLIC_ENTE_ENV, which has the same semantics as
|
||||
*
|
||||
*
|
||||
* If the environment variable NODE_ENV is unassigned, Next.js automatically
|
||||
assigns development when running the next dev command, or production for all
|
||||
other commands.
|
||||
* next sets NODE_ENV to `production`.
|
||||
* When we run
|
||||
* `yarn dev:foo`, it invokes `next dev`, which sets NODE_ENV to
|
||||
* 'development'. In all other cases (say, `next build`),
|
||||
*
|
||||
|
||||
It's a dev deployment (and should use the environment override for endpoints )
|
||||
in three cases:
|
||||
1. when the URL opened is that of the staging web app, or
|
||||
2. when the URL opened is that of the staging album app, or
|
||||
3. if the app is running locally (hence node_env is development)
|
||||
4. if the app is running in test mode
|
||||
*/
|
||||
* > If the environment variable NODE_ENV is unassigned, Next.js
|
||||
* automatically assigns development when running the `next dev` command,
|
||||
* or production for all other commands.
|
||||
*/
|
||||
export const isDevDeployment = () => {
|
||||
if (globalThis?.location) {
|
||||
return (
|
||||
process.env.NEXT_PUBLIC_ENTE_WEB_ENDPOINT ===
|
||||
globalThis.location.origin ||
|
||||
process.env.NEXT_PUBLIC_ENTE_ALBUM_ENDPOINT ===
|
||||
globalThis.location.origin ||
|
||||
process.env.NEXT_PUBLIC_IS_TEST_APP === 'true' ||
|
||||
process.env.NODE_ENV === 'development'
|
||||
);
|
||||
}
|
||||
return process.env.NODE_ENV === 'development';
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue