Skip to content

Commit

Permalink
chore: manually chunk console assets (#3691)
Browse files Browse the repository at this point in the history
Fix the build warning

> (!) Some chunks are larger than 500 kB after minification. Consider:
    - Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking:
https://rollupjs.org/configuration-options/#output-manualchunks
- Adjust chunk size limit for this warning via
build.chunkSizeWarningLimit.


BEFORE:
```sh
> tsc && vite build

vite v6.0.3 building for production...
✓ 4989 modules transformed.
dist/index.html                       0.66 kB │ gzip:   0.42 kB
dist/assets/favicon-jjzVXmZJ.ico     15.41 kB
dist/assets/index-YNQQSvAV.css       53.74 kB │ gzip:   9.32 kB
dist/assets/index-CUF64-92.js     2,292.08 kB │ gzip: 718.16 kB

(!) Some chunks are larger than 500 kB after minification. Consider:
- Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
✓ built in 4.46s
```

AFTER:
```sh
> tsc && vite build

vite v6.0.3 building for production...
✓ 4989 modules transformed.
dist/index.html                                       1.61 kB │ gzip:   0.60 kB
dist/assets/favicon-jjzVXmZJ.ico                     15.41 kB
dist/assets/index-YNQQSvAV.css                       53.74 kB │ gzip:   9.32 kB
dist/assets/vendor-fuse-CU2r43ac.js                  15.78 kB │ gzip:   5.41 kB
dist/assets/vendor-highlightjs-C-pAAiiO.js           20.80 kB │ gzip:   8.36 kB
dist/assets/vendor-json-schema-library-Dn37TOo0.js   94.96 kB │ gzip:  27.33 kB
dist/assets/vendor-yaml-DPZo3Gqr.js                 105.03 kB │ gzip:  32.43 kB
dist/assets/vendor-protos-C_tG9BVl.js               120.39 kB │ gzip:  22.10 kB
dist/assets/vendor-fcose-CGf29ClP.js                124.33 kB │ gzip:  34.47 kB
dist/assets/vendor-ui-1mIdG35Z.js                   179.39 kB │ gzip:  57.26 kB
dist/assets/vendor-react-DSWsB37T.js                217.84 kB │ gzip:  71.72 kB
dist/assets/vendor-json-schema-faker-DIbJIIw-.js    272.80 kB │ gzip:  88.83 kB
dist/assets/vendor-codemirror-ledrZVpE.js           370.30 kB │ gzip: 120.67 kB
dist/assets/index-BGXxIlqa.js                       376.45 kB │ gzip: 125.19 kB
dist/assets/vendor-graph-D78d43xQ.js                379.52 kB │ gzip: 122.07 kB
✓ built in 4.60s
```
  • Loading branch information
wesbillman authored Dec 9, 2024
1 parent 546a895 commit ae653a6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
11 changes: 4 additions & 7 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"protoc": {
"path": "${workspaceRoot}/bin/protoc",
"options": [
"--proto_path=${workspaceRoot}/backend/protos"
]
"path": "${workspaceRoot}/bin/protoc",
"options": ["--proto_path=${workspaceRoot}/backend/protos"]
},
"[python]": {
"editor.formatOnSave": true,
Expand All @@ -13,7 +11,6 @@
"source.organizeImports": "explicit"
}
},
"python.analysis.extraPaths": [
"./python-runtime/ftl/src"
]
"python.analysis.extraPaths": ["./python-runtime/ftl/src"],
"npm.packageManager": "pnpm"
}
34 changes: 34 additions & 0 deletions frontend/console/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,38 @@ export default defineConfig({
localsConvention: 'camelCaseOnly',
},
},
build: {
rollupOptions: {
output: {
manualChunks: {
'vendor-react': ['react', 'react-dom', 'react-router-dom'],
'vendor-graph': ['cytoscape'],
'vendor-fcose': ['cytoscape-fcose'],
'vendor-ui': ['@headlessui/react', '@tanstack/react-query'],
'vendor-json-schema-faker': ['json-schema-faker'],
'vendor-json-schema-library': ['json-schema-library'],
'vendor-yaml': ['yaml'],
'vendor-highlightjs': ['highlight.js'],
'vendor-fuse': ['fuse.js'],
'vendor-codemirror': [
'@codemirror/autocomplete',
'@codemirror/commands',
'@codemirror/lang-json',
'@codemirror/language',
'@codemirror/lint',
'@codemirror/state',
'@codemirror/view',
],
'vendor-protos': [
'./src/protos/xyz/block/ftl/console/v1/console_pb',
'./src/protos/xyz/block/ftl/console/v1/console_connect',
'./src/protos/xyz/block/ftl/schema/v1/schema_pb',
'./src/protos/xyz/block/ftl/timeline/v1/event_pb',
'./src/protos/xyz/block/ftl/timeline/v1/timeline_pb',
'./src/protos/xyz/block/ftl/timeline/v1/timeline_connect',
],
},
},
},
},
})

0 comments on commit ae653a6

Please sign in to comment.