Skip to content

Commit

Permalink
[UNI-312] feat: compression plugin 제공 및 파일 서빙 제공
Browse files Browse the repository at this point in the history
  • Loading branch information
jpark0506 committed Feb 20, 2025
1 parent 9a576a7 commit d3b21c6
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 3 deletions.
20 changes: 18 additions & 2 deletions uniro_frontend/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,30 @@ http {
brotli_comp_level 11;
brotli_types text/plain text/css application/json application/javascript text/xml application/xml+rss image/svg+xml;

map $http_accept_encoding $enc_ext {
default "";
"~*br" ".br";
"~*gzip" ".gz";
}

server {
listen 3000;
server_name localhost;
listen 3000;
server_name localhost;

location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri /index.html;
}

location ~* \.(css|js|html|json|svg|xml|txt|ico)$ {
add_header Cache-Control "public, max-age=31536000, immutable";
add_header Vary Accept-Encoding;

try_files $uri$enc_ext $uri;
if ($enc_ext != "") {
add_header Content-Encoding $enc_ext;
}
}
}
}
54 changes: 54 additions & 0 deletions uniro_frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions uniro_frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"typescript": "~5.6.2",
"typescript-eslint": "^8.18.2",
"vite": "^6.0.5",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-svgr": "^4.3.0"
}
}
17 changes: 16 additions & 1 deletion uniro_frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,23 @@ import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import tailwindcss from "@tailwindcss/vite";
import svgr from "vite-plugin-svgr";
import compression from "vite-plugin-compression";

// https://vite.dev/config/
export default defineConfig({
plugins: [react(), tailwindcss(), svgr()],
plugins: [
react(),
tailwindcss(),
svgr(),
compression({
algorithm: "brotliCompress",
ext: ".br",
threshold: 1024,
deleteOriginFile: false,
}),
compression({
algorithm: "gzip",
ext: ".gz",
}),
],
});

0 comments on commit d3b21c6

Please sign in to comment.