Add SaaS frontend code (#5879)

# Description of Changes
Adds the code for the SaaS frontend as proprietary code to the OSS repo.
This version of the code is adapted from 22/1/2026, which was the last
SaaS version based on the 'V2' design. This will move us closer to being
able to have the OSS products understand whether the user has a SaaS
account, and provide the correct UI in those cases.
This commit is contained in:
James Brunton
2026-03-11 11:53:54 +00:00
committed by GitHub
parent 8bc37bf5ae
commit fa8c52b2be
114 changed files with 12408 additions and 99 deletions
+19 -17
View File
@@ -2,7 +2,16 @@ import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react-swc';
import tsconfigPaths from 'vite-tsconfig-paths';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import path from 'path';
const VALID_MODES = ['core', 'proprietary', 'saas', 'desktop'] as const;
type BuildMode = typeof VALID_MODES[number];
const TSCONFIG_MAP: Record<BuildMode, string> = {
core: './tsconfig.core.vite.json',
proprietary: './tsconfig.proprietary.vite.json',
saas: './tsconfig.saas.vite.json',
desktop: './tsconfig.desktop.vite.json',
};
export default defineConfig(({ mode }) => {
@@ -11,15 +20,15 @@ export default defineConfig(({ mode }) => {
// `VITE_` prefix.
const env = loadEnv(mode, process.cwd(), '')
// When DISABLE_ADDITIONAL_FEATURES is false (or unset), enable proprietary features
const isProprietary = process.env.DISABLE_ADDITIONAL_FEATURES !== 'true';
const isDesktopMode =
mode === 'desktop' ||
env.STIRLING_DESKTOP === 'true' ||
env.VITE_DESKTOP === 'true';
// Resolve the effective build mode.
// Explicit --mode flags take precedence; otherwise default to proprietary
// unless DISABLE_ADDITIONAL_FEATURES=true, in which case default to core.
const effectiveMode: BuildMode = (VALID_MODES as readonly string[]).includes(mode)
? (mode as BuildMode)
: process.env.DISABLE_ADDITIONAL_FEATURES === 'true' ? 'core' : 'proprietary';
// Validate required environment variables for desktop builds
if (isDesktopMode) {
if (effectiveMode === 'desktop') {
const requiredEnvVars = [
'VITE_SAAS_SERVER_URL',
'VITE_SUPABASE_PUBLISHABLE_DEFAULT_KEY',
@@ -35,9 +44,7 @@ export default defineConfig(({ mode }) => {
}
}
const baseProject = isProprietary ? './tsconfig.proprietary.vite.json' : './tsconfig.core.vite.json';
const desktopProject = isProprietary ? './tsconfig.desktop.vite.json' : baseProject;
const tsconfigProject = isDesktopMode ? desktopProject : baseProject;
const tsconfigProject = TSCONFIG_MAP[effectiveMode];
return {
plugins: [
@@ -71,7 +78,7 @@ export default defineConfig(({ mode }) => {
ignored: ['**/src-tauri/**'],
},
// Only use proxy in web mode - Tauri handles backend connections directly
proxy: isDesktopMode ? undefined : {
proxy: effectiveMode === 'desktop' ? undefined : {
'/api': {
target: 'http://localhost:8080',
changeOrigin: true,
@@ -117,10 +124,5 @@ export default defineConfig(({ mode }) => {
},
},
base: env.RUN_SUBPATH ? `/${env.RUN_SUBPATH}` : './',
resolve: {
alias: {
'posthog-js/react': path.resolve(__dirname, 'node_modules/posthog-js/react/dist/esm/index.js'),
},
},
};
});