Skip to content

Commit 33c1580

Browse files
committed
fix: setup env
1 parent b8e0aa2 commit 33c1580

9 files changed

Lines changed: 102 additions & 36 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,21 @@ jobs:
3232
- name: Install dependencies
3333
run: npm ci
3434

35-
- name: Create .env file
36-
run: |
37-
echo "VITE_GA4_ENABLED=true" >> .env
38-
echo "VITE_GA4_MEASUREMENT_ID=G-Y8CJ897DR7" >> .env
39-
echo "VITE_ADSENSE_ENABLED=true" >> .env
40-
echo "VITE_ADSENSE_PUBLISHER_ID=ca-pub-9436560391944255" >> .env
41-
echo "VITE_GA4_API_ENABLED=false" >> .env
42-
4335
- name: Build
4436
run: npm run build
45-
37+
env:
38+
MODE: production
39+
VITE_GA4_ENABLED: true
40+
VITE_GA4_MEASUREMENT_ID: G-Y8CJ897DR7
41+
VITE_ADSENSE_ENABLED: true
42+
VITE_ADSENSE_PUBLISHER_ID: ca-pub-9436560391944255
43+
VITE_GA4_API_ENABLED: false
4644
- name: Setup Pages
4745
uses: actions/configure-pages@v4
48-
4946
- name: Upload artifact
5047
uses: actions/upload-pages-artifact@v3
5148
with:
5249
path: "./dist"
53-
5450
deploy:
5551
environment:
5652
name: github-pages

index.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
/>
2828
<meta
2929
property="og:image"
30-
content="https://devtoolkit.mingrammer.com/og-image.png"
30+
content="https://devtoolkit.mingrammer.com/og-image.svg"
3131
/>
3232
<meta property="og:site_name" content="DevToolKit" />
3333

@@ -44,7 +44,7 @@
4444
/>
4545
<meta
4646
name="twitter:image"
47-
content="https://devtoolkit.mingrammer.com/og-image.png"
47+
content="https://devtoolkit.mingrammer.com/og-image.svg"
4848
/>
4949

5050
<!-- Additional SEO -->
@@ -71,7 +71,7 @@
7171

7272
<!-- Favicon -->
7373
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
74-
<link rel="icon" type="image/png" href="/favicon.png" />
74+
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
7575

7676
<!-- Structured Data -->
7777
<script type="application/ld+json">
@@ -108,8 +108,6 @@
108108

109109
<body>
110110
<div id="root"></div>
111-
<!-- IMPORTANT: DO NOT REMOVE THIS SCRIPT TAG OR THIS VERY COMMENT! -->
112-
<script src="https://cdn.gpteng.co/gptengineer.js" type="module"></script>
113111
<script type="module" src="/src/main.tsx"></script>
114112
</body>
115113
</html>

public/favicon-note.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# favicon.png는 바이너리 파일이므로 기존 favicon.ico를 복사하거나 별도 생성 필요
2+
# 현재 favicon.ico가 있으므로 index.html에서 해당 경로만 수정

public/favicon.svg

Lines changed: 11 additions & 0 deletions
Loading

public/og-image.svg

Lines changed: 53 additions & 0 deletions
Loading

src/components/DevInfo.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ const DevInfo = () => {
7474
{envInfo.isGH ? "🟢" : "⚪"} GitHub
7575
</Badge>
7676
</div>
77-
<div className="text-gray-500 mt-1">Mode: {envInfo.mode}</div>
77+
<div className="text-gray-500 mt-1">
78+
<div>Mode: {envInfo.mode}</div>
79+
<div>Host: {typeof window !== 'undefined' ? window.location.hostname : 'unknown'}</div>
80+
</div>
7881
</div>
7982

8083
{/* Analytics 상태 */}

src/config/analytics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const validateConfig = () => {
5353
};
5454

5555
// 설정 로그 출력 (개발 환경에서만)
56-
if (typeof window !== 'undefined' && getEnvVar('NODE_ENV') !== 'production') {
56+
if (typeof window !== 'undefined' && getEnvVar('MODE') !== 'production') {
5757
console.log('🔧 Analytics Config:', {
5858
ga4: {
5959
enabled: analyticsConfig.ga4.enabled,

src/utils/environment.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,36 @@
1-
// 개발 환경 감지 유틸리티
21
export const isDevelopment = () => {
32
try {
4-
return import.meta.env?.MODE === 'development' ||
5-
import.meta.env?.DEV === true ||
6-
window.location.hostname === 'localhost' ||
7-
window.location.hostname === '127.0.0.1' ||
8-
window.location.port !== '';
3+
if (import.meta.env?.MODE === 'development' || import.meta.env?.DEV === true) {
4+
return true;
5+
}
6+
7+
if (typeof window !== 'undefined') {
8+
const hostname = window.location.hostname;
9+
return hostname === 'localhost' ||
10+
hostname === '127.0.0.1' ||
11+
hostname.startsWith('192.168.') ||
12+
hostname.startsWith('10.') ||
13+
window.location.port !== '';
14+
}
15+
16+
return false;
917
} catch {
1018
return false;
1119
}
1220
};
1321

14-
// 프로덕션 환경 감지
1522
export const isProduction = () => {
1623
try {
17-
return import.meta.env?.MODE === 'production' &&
18-
import.meta.env?.PROD === true;
24+
if (import.meta.env?.MODE === 'production' || import.meta.env?.PROD === true) {
25+
return true;
26+
}
27+
28+
return !isDevelopment();
1929
} catch {
20-
return false;
30+
return true;
2131
}
2232
};
2333

24-
// GitHub Pages 환경 감지
2534
export const isGitHubPages = () => {
2635
try {
2736
return window.location.hostname.includes('github.io');
@@ -30,7 +39,6 @@ export const isGitHubPages = () => {
3039
}
3140
};
3241

33-
// 광고 차단기 감지
3442
export const isAdBlockerActive = async (): Promise<boolean> => {
3543
try {
3644
const testAd = document.createElement('div');
@@ -53,8 +61,6 @@ export const isAdBlockerActive = async (): Promise<boolean> => {
5361
return false;
5462
}
5563
};
56-
57-
// 스크립트 로딩 상태 관리
5864
class ScriptLoader {
5965
private static loadedScripts = new Set<string>();
6066

@@ -66,7 +72,6 @@ class ScriptLoader {
6672
timeout?: number;
6773
} = {}): Promise<boolean> {
6874
return new Promise((resolve) => {
69-
// 이미 로드된 스크립트는 다시 로드하지 않음
7075
if (this.loadedScripts.has(src)) {
7176
resolve(true);
7277
return;
@@ -101,7 +106,6 @@ class ScriptLoader {
101106
resolve(false);
102107
};
103108

104-
// 타임아웃 설정 (기본 10초)
105109
if (options.timeout) {
106110
timeoutId = window.setTimeout(() => {
107111
options.onError?.(new Error('Script loading timeout'));
@@ -124,7 +128,6 @@ class ScriptLoader {
124128

125129
export { ScriptLoader };
126130

127-
// 안전한 console 로깅
128131
export const safeLog = {
129132
info: (message: string, ...args: any[]) => {
130133
if (!isProduction()) {

vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { componentTagger } from "lovable-tagger";
55

66
// https://vitejs.dev/config/
77
export default defineConfig(({ mode }) => ({
8-
base: mode === 'production' ? '/devtoolkit/' : '/', // GitHub Pages 배포를 위한 base path 설정
8+
base: '/', // Custom domain 사용 시 base path 제거
99
server: {
1010
host: "::",
1111
port: 8080,

0 commit comments

Comments
 (0)