Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules/
public/build/
public/index.html
dist/
coverage/
test-results/
Expand Down
5 changes: 0 additions & 5 deletions frontend/nginx.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ server {
expires 1y;
}

# Cache build directory assets with long expiry
location /build/ {
expires 1y;
}

# HTML files should not be cached
location ~* \.html$ {
expires -1;
Expand Down
40 changes: 40 additions & 0 deletions frontend/package-lock.json

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

2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"@playwright/test": "^1.58.2",
"@rollup/plugin-alias": "^6.0.0",
"@rollup/plugin-commonjs": "^29.0.0",
"@rollup/plugin-html": "^2.0.0",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^16.0.3",
"@rollup/plugin-replace": "^6.0.1",
Expand Down Expand Up @@ -79,6 +80,7 @@
"prettier": "^3.8.1",
"prettier-plugin-svelte": "^3.5.1",
"rollup": "^4.59.0",
"rollup-plugin-cleandir": "^3.0.0",
"rollup-plugin-css-only": "^4.3.0",
"rollup-plugin-livereload": "^2.0.0",
"rollup-plugin-postcss": "^4.0.2",
Expand Down
42 changes: 37 additions & 5 deletions frontend/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ import replace from '@rollup/plugin-replace';
import typescript from '@rollup/plugin-typescript';
import alias from '@rollup/plugin-alias';
import dotenv from 'dotenv';
import fs from 'fs';
import https from 'https';
import path from 'path';
import crypto from 'node:crypto';
import fs from 'node:fs';
import https from 'node:https';
import path from 'node:path';
import json from '@rollup/plugin-json';
import html from '@rollup/plugin-html';
import { cleandir } from 'rollup-plugin-cleandir';

// Path aliases - must match tsconfig.json paths
const projectRoot = path.resolve('.');
Expand Down Expand Up @@ -134,7 +137,9 @@ export default {
sourcemap: !production,
format: 'es',
name: 'app',
dir: 'public/build',
dir: 'public',
entryFileNames: production ? 'build/[name]-[hash].js' : 'build/[name].js',
chunkFileNames: 'build/[name]-[hash].js',
manualChunks: {
'vendor': [
'svelte',
Expand Down Expand Up @@ -175,7 +180,7 @@ export default {
}
}),
postcss({
extract: 'bundle.css',
extract: 'build/bundle.css',
minimize: false,
}),
typescript({
Expand All @@ -199,6 +204,33 @@ export default {
startServer();
}
},
production && cleandir('public/build', { hook: 'generateBundle' }),
production && {
name: 'css-hash',
generateBundle(_, bundle) {
const css = bundle['build/bundle.css'];
if (!css) return;
const hash = crypto.createHash('sha256').update(css.source).digest('hex').slice(0, 8);
const name = `build/bundle-${hash}.css`;
css.fileName = name;
bundle[name] = css;
delete bundle['build/bundle.css'];
},
},
html({
template({ bundle }) {
let tmpl = fs.readFileSync('src/index.html', 'utf-8');
const entryChunk = Object.values(bundle).find(f => f.type === 'chunk' && f.isEntry);
const cssAsset = Object.values(bundle).find(f => f.type === 'asset' && f.fileName.endsWith('.css'));
if (cssAsset) {
tmpl = tmpl.replace('</head>', ` <link rel="stylesheet" href="/${cssAsset.fileName}">\n</head>`);
}
if (entryChunk) {
tmpl = tmpl.replace('</body>', ` <script nonce="**CSP_NONCE**" type="module" src="/${entryChunk.fileName}"></script>\n</body>`);
}
return tmpl;
},
}),
production && terser({
ecma: 2020,
module: true,
Expand Down
3 changes: 0 additions & 3 deletions frontend/public/index.html → frontend/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,17 @@
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
</style>

<link rel="stylesheet" href="/build/bundle.css">
<script nonce="**CSP_NONCE**" type="module" src='/build/main.js'></script>
</head>

<body>
<div id="app-loading" class="app-loading" role="status" aria-live="polite" aria-busy="true">

Check warning on line 36 in frontend/src/index.html

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use <output> instead of the status role to ensure accessibility across all devices.

See more on https://sonarcloud.io/project/issues?id=HardMax71_Integr8sCode&issues=AZzE1vws3rRGJkHAPStx&open=AZzE1vws3rRGJkHAPStx&pullRequest=269
<div class="app-loading-inner">
<div class="app-loading-spinner" aria-hidden="true"></div>
<span class="sr-only">Loading…</span>
</div>
</div>
<script nonce="**CSP_NONCE**">
window.addEventListener('DOMContentLoaded', () => {

Check warning on line 43 in frontend/src/index.html

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `globalThis` over `window`.

See more on https://sonarcloud.io/project/issues?id=HardMax71_Integr8sCode&issues=AZzE1vws3rRGJkHAPStv&open=AZzE1vws3rRGJkHAPStv&pullRequest=269
setTimeout(() => {
const loader = document.getElementById('app-loading');
if (loader) loader.classList.add('app-loading-hidden');
Expand Down
Loading