Files
2nd/10_Wiki/Topic_Programming/Frontend/성능 최적화가 필수적인 대규모 다중 테마 플랫폼.md
T
Antigravity Agent 9148c358d0 docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를
Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류.

- 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로
  자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거,
  동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거.
- 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming,
  Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business,
  Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로,
  나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는
  title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백).
  원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지.
- 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서.
- 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는
  지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지.
- Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경.
- 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
2026-07-05 00:33:48 +09:00

7.5 KiB
Raw Blame History

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-성능-최적화가-필수적인-대규모-다중-테마-플랫폼 성능 최적화가 필수적인 대규모 다중 테마 플랫폼 10_Wiki/Topics verified self
Multi-theme Platform Performance
White-label SaaS Optimization
CSS Variable Theming
none A 0.85 applied
frontend
performance
theming
white-label
css-variables
design-tokens
case-study
2026-05-10 pending
language framework
TypeScript / CSS Next.js 15, Tailwind CSS v4, Vanilla Extract, Style Dictionary

성능 최적화가 필수적인 대규모 다중 테마 플랫폼

매 한 줄

"매 다중 테마 platform — 매 50+ 의 tenant brand 의 동시 serving — 매 CSS 의 cardinality explosion, 매 build size, 매 runtime switching 의 3중 문제". 매 naive approach (매 brand 별 separate CSS bundle) 의 매 build time exponential 폭증 + 매 tenant 의 추가 의 redeploy. 매 modern 해결 (2026): CSS custom properties + design token system + runtime theming + edge-cached CSS.

매 핵심

매 Multi-tenant Theming 의 challenge

  • Build complexity — 매 brand × variant × feature flag 의 polynomial 의 CSS variant.
  • Bundle size — 매 tenant 별 CSS 의 ship → 매 cache miss.
  • Runtime switching — 매 user 의 brand toggle (preview, white-label admin).
  • Style isolation — 매 tenant A 의 CSS 의 tenant B 의 affect X.
  • Brand consistency — 매 design token 의 single source of truth.

매 Modern Architecture (2026)

  1. Design token JSON — 매 brand 별 token (color, spacing, typography, radius).
  2. Token build (Style Dictionary, Tokens Studio) → CSS variables.
  3. Single CSS bundle — 매 모든 brand 의 fallback variable.
  4. Runtime theme injection — 매 <html data-brand="acme"> + 매 brand-specific :root block.
  5. Edge caching — Cloudflare Workers 의 brand-aware CSS serving.

매 Performance Pillar

  • CSS variable 의 사용 — 매 brand swap 의 매 reflow 의 X (매 paint 만).
  • Container queries — 매 component-scoped responsive, 매 tenant layout 의 격리.
  • CSS containment — 매 brand widget 의 layout boundary.
  • Server-rendered initial brand — 매 FOUC 의 방지.

💻 패턴

Pattern 1: Design Token → CSS Variables

// tokens/acme.json
{
  "color": {
    "primary": { "value": "#ff5500" },
    "background": { "value": "#ffffff" },
    "text": { "value": "#222222" }
  },
  "radius": { "md": { "value": "8px" } }
}
// build/style-dictionary.config.js
module.exports = {
  source: ['tokens/**/*.json'],
  platforms: {
    css: {
      transformGroup: 'css',
      buildPath: 'dist/css/',
      files: [{
        destination: 'tokens.css',
        format: 'css/variables',
        options: { outputReferences: true },
      }]
    }
  }
};
/* dist/css/tokens.css (compiled) */
[data-brand="acme"] {
  --color-primary: #ff5500;
  --color-background: #ffffff;
  --radius-md: 8px;
}
[data-brand="globex"] {
  --color-primary: #0066ff;
  --color-background: #f0f4f8;
  --radius-md: 4px;
}

Pattern 2: Runtime Brand Switching (no reflow)

// app/providers/BrandProvider.tsx
'use client';
import { useEffect } from 'react';

export function BrandProvider({ brand, children }: { brand: string, children: React.ReactNode }) {
  useEffect(() => {
    document.documentElement.dataset.brand = brand;
  }, [brand]);
  return <>{children}</>;
}

Pattern 3: SSR Brand Detection (FOUC 방지)

// app/layout.tsx
import { headers } from 'next/headers';

export default async function RootLayout({ children }: { children: React.ReactNode }) {
  const host = (await headers()).get('host') ?? '';
  const brand = await resolveBrand(host); // acme.example.com → "acme"
  return (
    <html lang="en" data-brand={brand}>
      <body>{children}</body>
    </html>
  );
}

Pattern 4: Tailwind v4 with CSS Variables (2026)

/* app.css — Tailwind v4 의 native CSS variable */
@import "tailwindcss";

@theme {
  --color-primary: var(--color-primary);
  --color-bg: var(--color-background);
  --radius-md: var(--radius-md);
}
<button className="bg-primary text-white rounded-md px-4 py-2">
  Click me
</button>

Pattern 5: Edge-Cached Brand CSS

// middleware.ts (Next.js)
import { NextResponse } from 'next/server';
export function middleware(req: Request) {
  const host = new URL(req.url).hostname;
  const brand = brandMap[host] ?? 'default';
  const res = NextResponse.next();
  res.headers.set('x-brand', brand);
  res.headers.set('Cache-Control', 'public, max-age=3600, s-maxage=86400');
  res.headers.set('Vary', 'Host');
  return res;
}

Pattern 6: Vanilla Extract (zero-runtime CSS-in-TS)

// theme.css.ts
import { createGlobalTheme, createThemeContract } from '@vanilla-extract/css';

export const vars = createThemeContract({
  color: { primary: null, bg: null },
  radius: { md: null },
});

createGlobalTheme('[data-brand="acme"]', vars, {
  color: { primary: '#ff5500', bg: '#fff' },
  radius: { md: '8px' },
});

Pattern 7: Container Queries 의 격리

.tenant-widget {
  container-type: inline-size;
  container-name: widget;
}

@container widget (min-width: 600px) {
  .card { display: grid; grid-template-columns: 1fr 1fr; }
}

Pattern 8: Critical CSS Extraction

// 매 SSR 시 매 brand 별 critical CSS 의 inline
import critical from 'critical';

await critical.generate({
  base: 'dist/',
  src: `index-${brand}.html`,
  inline: true,
  width: 1300,
  height: 900,
});

매 결정 기준

상황 Approach
5+ tenants Design tokens + CSS variables
Runtime preview data-brand attribute swap
White-label SaaS SSR brand resolution + edge cache
Tightly-controlled brands Vanilla Extract / Linaria
Marketing sites Tailwind v4 + token import
FOUC prevention SSR + inline critical CSS
Performance budget Lighthouse CI per brand

기본값: Design tokens (Style Dictionary) → CSS variables → Tailwind v4 utilities → SSR brand attribute → edge-cached.

🔗 Graph

🤖 LLM 활용

언제: 매 token system 의 schema 설계, 매 tenant 추가 시 의 build pipeline 의 review, FOUC 의 troubleshoot. 언제 X: 매 brand 의 actual color palette 의 결정 — 매 design 의 영역.

안티패턴

  • Brand 별 separate CSS bundle: 매 build matrix 폭발, 매 cache miss.
  • JavaScript 의 inline style 의 swap: 매 매 element 의 매 re-render.
  • CSS-in-JS runtime overhead: 매 매 component mount 의 style serialization.
  • Token 의 CSS 의 hardcoded duplication: 매 token 의 single source of truth 의 위반.
  • Brand resolution 의 client-only: 매 FOUC, 매 layout shift.

🧪 검증 / 중복

  • Verified (Style Dictionary docs, Tailwind v4 release notes, Vanilla Extract docs, Vercel multi-tenant template 2026).
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — design token pipeline, runtime theming, edge caching, FOUC prevention