Skip to content
Draft
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
10 changes: 5 additions & 5 deletions 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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"sinon": "^21.0.1",
"sinon-chai": "^4.0.0",
"tailwindcss": "^4.1.18",
"terser": "^5.46.0",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.7.2",
"typescript-eslint": "^8.26.0",
Expand Down
12 changes: 12 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ export default defineConfig(({ mode }) => {
outDir: "static", // Webpack outputs to 'static', assuming we want to keep this.
emptyOutDir: true,
assetsDir: "assets", // Sub-directory for assets
sourcemap: !isProduction, // Source maps for dev builds only
minify: isProduction ? "terser" : false,
...(isProduction && {
terserOptions: {
toplevel: true, // Mangle top-level names and drop unused top-level vars/functions
compress: { passes: 3 },
mangle: { toplevel: true }, // Shorten top-level function/variable names
format: {
comments: false,
},
},
}),
Comment on lines 100 to 110
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Risk: comments: false strips license comments from bundled libraries.

Setting format.comments: false removes all comments, including license and legal notices from third-party packages (pixi.js, howler, zod, protobufjs, etc.). Many open-source licenses (MIT, Apache-2.0, BSD) require attribution to be preserved in distributed code. Stripping them may violate license terms.

Use comments: "some" or a regex to keep license banners, or pair this with a plugin like rollup-plugin-license to extract them into a separate LICENSE file in the output.

Suggested fix — keep license comments
       terserOptions: {
         compress: { passes: 2 },
         mangle: true,
         format: {
-          comments: false,
+          comments: /^\/*!/,  // keep comments starting with /*! (license banners)
         },
       },

Or extract all licenses into a separate file using a Rollup plugin, which keeps the bundle clean and stays compliant.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
minify: isProduction ? "terser" : false,
...(isProduction && {
terserOptions: {
compress: { passes: 2 },
mangle: true,
format: {
comments: false,
},
},
}),
minify: isProduction ? "terser" : false,
...(isProduction && {
terserOptions: {
compress: { passes: 2 },
mangle: true,
format: {
comments: /^\/*!/, // keep comments starting with /*! (license banners)
},
},
}),
🤖 Prompt for AI Agents
In `@vite.config.ts` around lines 100 - 109, The terser config currently sets
terserOptions.format.comments = false which strips all comments (including
required license headers); update the vite minify/terser options so license
comments are preserved by changing terserOptions.format.comments to "some" or a
regex that matches license banners, or alternatively add a Rollup plugin (e.g.,
a license extraction plugin) to collect and emit third‑party licenses into a
LICENSE file while keeping terserOptions.format.comments set to allow banner
preservation; locate the minify block/terserOptions in vite.config.ts (the
isProduction conditional) and adjust format.comments or add the license
extraction plugin accordingly.

rollupOptions: {
output: {
manualChunks: {
Expand Down
Loading