File tree Expand file tree Collapse file tree 3 files changed +16
-5
lines changed
Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ node_modules_bak/
6767
6868# dotenv environment variables file
6969.env
70+ .env *
7071
7172# vs code
7273.vscode /*
Original file line number Diff line number Diff line change 11import { defineConfig , mergeConfig } from "vite" ;
22import injectHTML from "vite-plugin-html-inject" ;
33import autoprefixer from "autoprefixer" ;
4- import "dotenv/config " ;
4+ import { config as dotenvConfig } from "dotenv" ;
55import PROD_CONFIG from "./vite.config.prod" ;
66import DEV_CONFIG from "./vite.config.dev" ;
77import MagicString from "magic-string" ;
88import { Fonts } from "./src/ts/constants/fonts" ;
99
10+ // Load environment variables based on NODE_ENV
11+ const envFile =
12+ process . env . NODE_ENV === "production" ? ".env.production" : ".env" ;
13+ dotenvConfig ( { path : envFile } ) ;
14+
1015/** @type {import("vite").UserConfig } */
1116const BASE_CONFIG = {
1217 plugins : [
@@ -63,8 +68,13 @@ const BASE_CONFIG = {
6368
6469export default defineConfig ( ( { command } ) => {
6570 if ( command === "build" ) {
71+ const envFileName =
72+ process . env . NODE_ENV === "production" ? ".env.production" : ".env" ;
6673 if ( process . env . RECAPTCHA_SITE_KEY === undefined ) {
67- throw new Error ( ".env: RECAPTCHA_SITE_KEY is not defined" ) ;
74+ throw new Error ( `${ envFileName } : RECAPTCHA_SITE_KEY is not defined` ) ;
75+ }
76+ if ( process . env . SENTRY && process . env . SENTRY_AUTH_TOKEN === undefined ) {
77+ throw new Error ( `${ envFileName } : SENTRY_AUTH_TOKEN is not defined` ) ;
6878 }
6979 return mergeConfig ( BASE_CONFIG , PROD_CONFIG ) ;
7080 } else {
Original file line number Diff line number Diff line change @@ -179,15 +179,15 @@ const buildProject = () => {
179179
180180 if ( isFrontend && ! isBackend ) {
181181 runProjectRootCommand (
182- "SENTRY=1 npx turbo lint test check-assets build --filter @monkeytype/frontend --force" ,
182+ "NODE_ENV=production SENTRY=1 npx turbo lint test check-assets build --filter @monkeytype/frontend --force" ,
183183 ) ;
184184 } else if ( isBackend && ! isFrontend ) {
185185 runProjectRootCommand (
186- "SENTRY=1 npx turbo lint test build --filter @monkeytype/backend --force" ,
186+ "NODE_ENV=production SENTRY=1 npx turbo lint test build --filter @monkeytype/backend --force" ,
187187 ) ;
188188 } else {
189189 runProjectRootCommand (
190- "SENTRY=1 npx turbo lint test check-assets build --force" ,
190+ "NODE_ENV=production SENTRY=1 npx turbo lint test check-assets build --force" ,
191191 ) ;
192192 }
193193} ;
You can’t perform that action at this time.
0 commit comments