Skip to content

Commit 7059982

Browse files
compress ALL THE THINGS
1 parent 222f7ae commit 7059982

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

core/frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
"typescript": "~4.9.5",
9595
"unplugin-vue-components": "^0.25.2",
9696
"vite": "3",
97+
"vite-plugin-compression": "^0.5.1",
9798
"vite-plugin-pwa": "^0.16.5",
9899
"vite-plugin-wasm": "^3.4.1",
99100
"vue-cli-plugin-vuetify": "~2.4.1",

core/frontend/vite.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Components from 'unplugin-vue-components/vite'
44
import { defineConfig, loadEnv } from 'vite'
55
import { sentryVitePlugin } from "@sentry/vite-plugin";
66
import { VitePWA } from 'vite-plugin-pwa'
7+
import viteCompression from 'vite-plugin-compression'
78
import wasm from "vite-plugin-wasm"
89
const { name } = require('./package.json')
910

@@ -100,6 +101,14 @@ export default defineConfig(({ command, mode }) => {
100101
removeNonJson(repoPath)
101102
}
102103
},
104+
// Pre-compress assets with gzip for nginx to serve via gzip_static always
105+
viteCompression({
106+
algorithm: 'gzip',
107+
ext: '.gz',
108+
threshold: 1024,
109+
deleteOriginFile: true,
110+
filter: /\.(js|css|json|svg|txt|xml|wasm)$/i,
111+
}),
103112
],
104113
assetsInclude: ['**/*.gif', '**/*.glb', '**/*.png', '**/*.svg', '**/*.msg', "**/three/examples/jsm/libs/draco/*"],
105114
resolve: {

core/tools/nginx/nginx.conf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ http {
2424
include /etc/nginx/mime.types;
2525
default_type application/octet-stream;
2626

27+
# Serve pre-compressed .gz files even without originals (requires client gzip support)
28+
gzip_static always;
29+
2730
# Cache
2831
proxy_cache_path /var/cache/nginx keys_zone=ourcache:10m levels=1:2 max_size=1g inactive=30d;
2932

@@ -265,7 +268,6 @@ http {
265268

266269
location /assets/ {
267270
root /home/pi/frontend;
268-
try_files $uri $uri/;
269271
autoindex on;
270272
add_header Cache-Control "public, max-age=604800";
271273
}

0 commit comments

Comments
 (0)