feat(web-platform): release V0.7 地图模块
web-platform-ci / TypeScript, lint, unit, build (push) Has been cancelled
web-platform-ci / Playwright E2E (push) Has been cancelled

This commit is contained in:
2026-09-01 14:23:49 +08:00
parent 60d3a6d68c
commit 3b4ced6437
58 changed files with 7287 additions and 269 deletions
+28 -3
View File
@@ -16,6 +16,27 @@ const pyodideDirectory = resolve(
'../node_modules/pyodide',
);
/** 生产预览中长期缓存带内容哈希的资源,同时允许入口文件及时更新。 */
function previewCacheHeaders(): Plugin {
return {
name: 'preview-cache-headers',
configurePreviewServer(server) {
server.middlewares.use((request, response, next) => {
const path = request.url?.split(/[?#]/, 1)[0] ?? '';
if (path.startsWith('/assets/'))
response.setHeader('Cache-Control', 'public, max-age=31536000, immutable');
else if (path.startsWith('/pyodide/'))
response.setHeader(
'Cache-Control',
'public, max-age=86400, stale-while-revalidate=604800',
);
else response.setHeader('Cache-Control', 'no-cache');
next();
});
},
};
}
/** 让开发服务器与生产构建都从本地 npm 包提供 Pyodide,保持平台可离线部署。 */
function localPyodideAssets(): Plugin {
let isBuild = false;
@@ -59,12 +80,16 @@ function localPyodideAssets(): Plugin {
export default defineConfig({
root: 'web_platform',
base: './',
plugins: [react(), localPyodideAssets()],
plugins: [react(), localPyodideAssets(), previewCacheHeaders()],
publicDir: 'public',
build: { outDir: '../web-platform-dist', emptyOutDir: true, target: 'es2022' },
build: {
outDir: '../web-platform-dist',
emptyOutDir: true,
target: 'es2022',
modulePreload: { polyfill: false },
},
worker: { format: 'es' },
server: { open: true, fs: { allow: ['..'] } },
preview: { headers: { 'Cache-Control': 'no-store' } },
test: {
globals: true,
environment: 'jsdom',