Separate environment configs (#6597)

* Separate environment configs

* wip

* wip

* test

* plugins

* test

* test

* .sequelizerc, unfortunately can't go through /utils/environment due to not supporting TS

* docker-compose -> docker compose

* fix: .local wipes .development

* Add custom validation message for invalid SECRET_KEY (often confused)
This commit is contained in:
Tom Moor
2024-02-27 09:24:23 -08:00
committed by GitHub
parent 415383a1c9
commit 60e52d0423
45 changed files with 489 additions and 409 deletions

View File

@@ -2,20 +2,15 @@ import fs from "fs";
import path from "path";
import react from "@vitejs/plugin-react";
import browserslistToEsbuild from "browserslist-to-esbuild";
import dotenv from "dotenv";
import { webpackStats } from "rollup-plugin-webpack-stats";
import { CommonServerOptions, defineConfig } from "vite";
import { VitePWA } from "vite-plugin-pwa";
import { viteStaticCopy } from "vite-plugin-static-copy";
// Load the process environment variables
dotenv.config({
silent: true,
});
import environment from "./server/utils/environment";
let httpsConfig: CommonServerOptions["https"] | undefined;
if (process.env.NODE_ENV === "development") {
if (environment.NODE_ENV === "development") {
try {
httpsConfig = {
key: fs.readFileSync("./server/config/certs/private.key"),
@@ -31,13 +26,13 @@ export default () =>
defineConfig({
root: "./",
publicDir: "./server/static",
base: (process.env.CDN_URL ?? "") + "/static/",
base: (environment.CDN_URL ?? "") + "/static/",
server: {
port: 3001,
host: true,
https: httpsConfig,
fs:
process.env.NODE_ENV === "development"
environment.NODE_ENV === "development"
? {
// Allow serving files from one level up to the project root
allow: [".."],
@@ -91,7 +86,7 @@ export default () =>
globPatterns: ["**/*.{js,css,ico,png,svg}"],
navigateFallback: null,
modifyURLPrefix: {
"": `${process.env.CDN_URL ?? ""}/static/`,
"": `${environment.CDN_URL ?? ""}/static/`,
},
runtimeCaching: [
{