chore: sync backend and deployment changes
This commit is contained in:
@@ -82,6 +82,42 @@ function createDevAppUpdatePlugin() {
|
||||
};
|
||||
}
|
||||
|
||||
function createDevServiceWorkerPlugin() {
|
||||
return {
|
||||
name: 'dev-service-worker-entry',
|
||||
apply: 'serve' as const,
|
||||
configureServer(server: ViteDevServer) {
|
||||
server.middlewares.use((request, response, next) => {
|
||||
const requestUrl = request.url?.trim() ?? '';
|
||||
const requestPath = requestUrl.split('?', 1)[0];
|
||||
|
||||
if (requestPath !== '/sw.js' && requestPath !== '/dev-sw.js') {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
void server
|
||||
.transformRequest('/src/sw.js')
|
||||
.then((result) => {
|
||||
if (!result?.code) {
|
||||
response.statusCode = 404;
|
||||
response.setHeader('Content-Type', 'text/plain; charset=utf-8');
|
||||
response.end('Not Found');
|
||||
return;
|
||||
}
|
||||
|
||||
response.statusCode = 200;
|
||||
response.setHeader('Content-Type', 'application/javascript; charset=utf-8');
|
||||
response.setHeader('Cache-Control', 'no-store');
|
||||
response.setHeader('Service-Worker-Allowed', '/');
|
||||
response.end(result.code);
|
||||
})
|
||||
.catch(next);
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function copyPublicAssetsExceptCodexChat() {
|
||||
let resolvedConfig: ResolvedConfig | null = null;
|
||||
|
||||
@@ -155,7 +191,7 @@ export default defineConfig({
|
||||
protocol: VITE_PUBLIC_HMR_PROTOCOL as 'ws' | 'wss',
|
||||
clientPort: VITE_PUBLIC_HMR_CLIENT_PORT,
|
||||
},
|
||||
allowedHosts: ['sm-home.cloud', 'test.sm-home.cloud', 'rel.sm-home.cloud'],
|
||||
allowedHosts: ['sm-home.cloud', 'test.sm-home.cloud', 'preview.sm-home.cloud', 'rel.sm-home.cloud'],
|
||||
watch: {
|
||||
ignored: (watchedPath) => shouldIgnoreDevUpdatePath(watchedPath),
|
||||
},
|
||||
@@ -178,28 +214,31 @@ export default defineConfig({
|
||||
preview: {
|
||||
host: '0.0.0.0',
|
||||
port: 5173,
|
||||
allowedHosts: ['sm-home.cloud', 'test.sm-home.cloud', 'rel.sm-home.cloud'],
|
||||
allowedHosts: ['sm-home.cloud', 'test.sm-home.cloud', 'preview.sm-home.cloud', 'rel.sm-home.cloud'],
|
||||
},
|
||||
plugins: [
|
||||
react(),
|
||||
createDevAppUpdatePlugin(),
|
||||
createDevServiceWorkerPlugin(),
|
||||
copyPublicAssetsExceptCodexChat(),
|
||||
!VITE_DISABLE_PWA &&
|
||||
VitePWA({
|
||||
injectRegister: null,
|
||||
strategies: 'injectManifest',
|
||||
srcDir: 'src',
|
||||
filename: 'sw.js',
|
||||
registerType: 'prompt',
|
||||
includeAssets: ['favicon.svg', 'apple-touch-icon.svg'],
|
||||
workbox: {
|
||||
globPatterns: ['**/*.{js,css,html,ico,svg,woff2,webmanifest}'],
|
||||
maximumFileSizeToCacheInBytes: 8 * 1024 * 1024,
|
||||
},
|
||||
injectManifest: {
|
||||
globPatterns: ['**/*.{js,css,html,ico,png,svg,webp,woff2}'],
|
||||
globIgnores: ['**/.codex_chat/**'],
|
||||
globIgnores: ['**/.codex_chat/**', '**/*.png', '**/*.webp'],
|
||||
maximumFileSizeToCacheInBytes: 8 * 1024 * 1024,
|
||||
},
|
||||
manifest: {
|
||||
id: '/',
|
||||
name: 'AI Code App',
|
||||
short_name: 'AI Code App',
|
||||
description: 'Ant Design 기반 UI 샘플과 문서를 확인하는 AI Code App',
|
||||
@@ -222,9 +261,24 @@ export default defineConfig({
|
||||
purpose: 'any maskable',
|
||||
},
|
||||
],
|
||||
shortcuts: [
|
||||
{
|
||||
name: 'E-Reader',
|
||||
short_name: 'E-Reader',
|
||||
description: '인터넷 기사와 웹 콘텐츠를 전자책처럼 읽습니다.',
|
||||
url: '/play/apps?app=e-reader',
|
||||
icons: [
|
||||
{
|
||||
src: '/pwa-192x192.svg',
|
||||
sizes: '192x192',
|
||||
type: 'image/svg+xml',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
devOptions: {
|
||||
enabled: true,
|
||||
enabled: false,
|
||||
},
|
||||
}),
|
||||
].filter(Boolean),
|
||||
|
||||
Reference in New Issue
Block a user