Skip to content

Commit

Permalink
feat: nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
Faizal Andyka committed Jul 16, 2021
1 parent 6dcd240 commit 3e7b863
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 2 deletions.
40 changes: 40 additions & 0 deletions nginx/nginx.dev.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;

location / {
try_files $uri $uri/ /index.html;

if ($request_method = OPTIONS) {
return 204;
}

add_header Access-Control-Allow-Origin *;
add_header Access-Control-Max-Age 3600;
add_header Access-Control-Expose-Headers Content-Length;
add_header Access-Control-Allow-Headers Range;
}

location ~* \.(eot|woff|woff2|ttf|otf)$ {
expires 30d;
add_header Cache-Control "public";

types {application/vnd.ms-fontobject eot;}
types {application/font-woff woff;}
types {font/x-woff woff2;}
types {font/truetype ttf;}
types {font/opentype otf;}
}

location ~* \.(jpg|jpeg|png|gif|ico|svg)$ {
expires 30d;
add_header Cache-Control "public";
}

location ~* \.(css|js)$ {
expires 7d;
add_header Cache-Control "no-cache, public, must-revalidate, proxy-revalidate";
}
}
40 changes: 40 additions & 0 deletions nginx/nginx.prod.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;

location / {
try_files $uri $uri/ /index.html;

if ($request_method = OPTIONS) {
return 204;
}

add_header Access-Control-Allow-Origin *;
add_header Access-Control-Max-Age 3600;
add_header Access-Control-Expose-Headers Content-Length;
add_header Access-Control-Allow-Headers Range;
}

location ~* \.(eot|woff|woff2|ttf|otf)$ {
expires 30d;
add_header Cache-Control "public";

types {application/vnd.ms-fontobject eot;}
types {application/font-woff woff;}
types {font/x-woff woff2;}
types {font/truetype ttf;}
types {font/opentype otf;}
}

location ~* \.(jpg|jpeg|png|gif|ico|svg)$ {
expires 30d;
add_header Cache-Control "public";
}

location ~* \.(css|js)$ {
expires 7d;
add_header Cache-Control "no-cache, public, must-revalidate, proxy-revalidate";
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@
"vuex": "^4.0.0"
},
"volta": {
"node": "14.16.1"
"node": "14.17.1"
}
}
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Learn the design patterns [here](https://github.com/logustra/7ad)
- Commit conventions: [commitizen](https://github.com/commitizen/cz-cli)
- Linters: [commitlint](https://github.com/conventional-changelog/commitlint), [eslint](https://github.com/eslint/eslint), [stylelint](https://github.com/stylelint/stylelint)
- Visualize bundle: [rollup-plugin-visualizer](https://github.com/btd/rollup-plugin-visualizer)
- Optimized nginx config (ON PROGRESS)
- Optimized nginx config
- Dockerize (ON PROGRESS)

## Dev Tools
Expand Down

0 comments on commit 3e7b863

Please sign in to comment.