Skip to content

Commit

Permalink
feat: improve loading speed (#23)
Browse files Browse the repository at this point in the history
* feat: improve loading speed

Signed-off-by: Jan Pokorný <[email protected]>

* fix: redirect to iambee.ai

Signed-off-by: Jan Pokorný <[email protected]>

---------

Signed-off-by: Jan Pokorný <[email protected]>
  • Loading branch information
JanPokorny authored Dec 12, 2024
1 parent c481465 commit 64e11c1
Show file tree
Hide file tree
Showing 10 changed files with 559 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ ENV VITE_ALLOWED_FRAME_ANCESTORS=${ALLOWED_FRAME_ANCESTORS}

ENV CI=1

ARG VITE_DEBUG
ENV VITE_DEBUG=${VITE_DEBUG}

COPY --from=deps ${APP_DIR}/node_modules ./node_modules
COPY . .

Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ pnpm dev

Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.

## Preloaded URLs

To update the list of preloaded URLs in `preload.json`:
1. Manually replace `preload.json` content with `{"urls":[]}`
2. Start `VITE_DEBUG=true pnpm start:dev` in one terminal
3. In a different terminal, run `node scripts/preload.mjs http://localhost:5173/`

## Bugs

We are using [GitHub Issues](https://github.com/i-am-bee/bee-usercontent-site/issues) to manage our public bugs. We keep a close eye on this, so before filing a new issue, please check to ensure it hasn't already been logged.
Expand Down
9 changes: 8 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@
<title>Bee Artifact Content</title>
<link rel="preload" href="/fonts/IBMPlexSans-Regular.woff2" as="font" crossorigin type="font/woff2">
<link rel="preload" href="/fonts/IBMPlexSans-SemiBold.woff2" as="font" crossorigin type="font/woff2">
<link rel="stylesheet" href="/<%= stlitePath %>/stlite.css" />
<% preloadItems.forEach(item => { %>
<% if(item.contentType === "application/vnd.pypi.simple.v1+json") { %>
<script>fetch("<%= item.url %>", { headers: { "Accept": "<%= item.contentType %>, */*;q=0.01", "Accept-Encoding": null } })</script>
<% } else { %>
<link rel="preload" href="<%= item.url %>" as="fetch" type="<%= item.contentType %>" crossorigin>
<% } %>
<% }); %>

<link rel="stylesheet" href="src/styles/style.scss" />
</head>

Expand Down
7 changes: 5 additions & 2 deletions nginx/default.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ server {

error_page 500 502 503 504 /50x.html;

etag on;

gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_min_length 1000;
gzip_types text/plain text/html text/css application/javascript application/json;

gzip_types text/plain text/html text/css application/javascript application/json application/wasm;

# SPA routing, everything falls back to the root index.html
location / {
Expand Down Expand Up @@ -48,6 +49,8 @@ server {
form-action 'self';
upgrade-insecure-requests;
" always;

if_modified_since before;
}

# Serve assets with immutable cache
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@typescript-eslint/parser": "^8.17.0",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"playwright": "^1.49.1",
"prettier": "^3.4.1",
"stylelint": "^16.11.0",
"stylelint-config-recommended-scss": "^14.1.0",
Expand All @@ -39,6 +40,7 @@
"@carbon/type": "^11.33.0",
"@release-it/conventional-changelog": "^9.0.3",
"@stlite/mountable": "^0.73.1",
"glob": "^11.0.0",
"release-it": "^17.10.0",
"sass": "^1.81.0"
},
Expand Down
Loading

0 comments on commit 64e11c1

Please sign in to comment.