perf(web): 优化静态资源缓存与代码分割
This commit is contained in:
@@ -23,6 +23,15 @@ server {
|
|||||||
gzip_vary on;
|
gzip_vary on;
|
||||||
gzip_types application/json application/javascript text/css text/plain image/svg+xml;
|
gzip_types application/json application/javascript text/css text/plain image/svg+xml;
|
||||||
|
|
||||||
|
# Vite assets use content hashes, so they are safe to cache across deployments.
|
||||||
|
# Keep index.html uncached below so it always points to the current asset manifest.
|
||||||
|
location ^~ /assets/ {
|
||||||
|
access_log off;
|
||||||
|
try_files $uri =404;
|
||||||
|
expires 1y;
|
||||||
|
add_header Cache-Control "public, max-age=31536000, immutable" always;
|
||||||
|
}
|
||||||
|
|
||||||
location ^~ /api/public/canvas-shares/ {
|
location ^~ /api/public/canvas-shares/ {
|
||||||
access_log off;
|
access_log off;
|
||||||
proxy_pass http://backend:8080;
|
proxy_pass http://backend:8080;
|
||||||
|
|||||||
@@ -40,8 +40,10 @@ export default defineConfig({
|
|||||||
output: {
|
output: {
|
||||||
strictExecutionOrder: true,
|
strictExecutionOrder: true,
|
||||||
codeSplitting: {
|
codeSplitting: {
|
||||||
includeDependenciesRecursively: true,
|
// Keep route-level lazy imports isolated. Recursively merging dependencies
|
||||||
minSize: 20 * 1024,
|
// pulls unrelated pages into the initial modulepreload graph.
|
||||||
|
includeDependenciesRecursively: false,
|
||||||
|
minSize: 40 * 1024,
|
||||||
groups: [
|
groups: [
|
||||||
{
|
{
|
||||||
name: "vendor-react",
|
name: "vendor-react",
|
||||||
@@ -62,14 +64,6 @@ export default defineConfig({
|
|||||||
entriesAware: true,
|
entriesAware: true,
|
||||||
entriesAwareMergeThreshold: 80 * 1024,
|
entriesAwareMergeThreshold: 80 * 1024,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "app-shared",
|
|
||||||
test: /[\\/]src[\\/]/,
|
|
||||||
priority: 5,
|
|
||||||
minShareCount: 2,
|
|
||||||
entriesAware: true,
|
|
||||||
entriesAwareMergeThreshold: 48 * 1024,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user