Skip to content

Commit

Permalink
Refacto constant
Browse files Browse the repository at this point in the history
  • Loading branch information
wiinxt committed Nov 23, 2022
1 parent 3b2f97c commit 6a06bf5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 36 deletions.
21 changes: 21 additions & 0 deletions site/source/types/app-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,24 @@ interface ImportMetaEnv {
*/
PROD: boolean
}

/**
* Git branch name
* This variable is statically replaced during the build
*/
declare const BRANCH_NAME: string

/**
* This variable is statically replaced during the build
*/
declare const IS_PRODUCTION: boolean

/**
* This variable is statically replaced during the build
*/
declare const IS_STAGING: boolean

/**
* This variable is statically replaced during the build
*/
declare const IS_DEVELOPMENT: boolean
24 changes: 0 additions & 24 deletions site/source/types/global.d.ts

This file was deleted.

23 changes: 11 additions & 12 deletions site/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ export default defineConfig(({ command, mode }) => ({
},
},
},
define: {
BRANCH_NAME: JSON.stringify(getBranch(mode)),
IS_DEVELOPMENT: mode === 'development',
IS_STAGING: mode === 'production' && !isProductionBranch(mode),
IS_PRODUCTION: mode === 'production' && isProductionBranch(mode),
},
plugins: [
{
name: 'run-script-on-file-change',
Expand All @@ -44,18 +50,11 @@ export default defineConfig(({ command, mode }) => ({
}
},
},
replace({
...(command === 'build' ? { __SENTRY_DEBUG__: false } : null),
BRANCH_NAME: JSON.stringify(getBranch(mode)),
IS_DEVELOPMENT: JSON.stringify(mode === 'development'),
IS_STAGING: JSON.stringify(
mode === 'production' && !isProductionBranch(mode)
),
IS_PRODUCTION: JSON.stringify(
mode === 'production' && isProductionBranch(mode)
),
preventAssignment: false,
}),
command === 'build' &&
replace({
__SENTRY_DEBUG__: false,
preventAssignment: false,
}),
react({
babel: {
plugins: [['babel-plugin-styled-components', { pure: true }]],
Expand Down

0 comments on commit 6a06bf5

Please sign in to comment.