typescript: {
enabled: true,
bundles: [
// No include: on every page
{ entryPoint: 'main.ts', bundleName: 'main' },
// The docs index and every page under it
{ entryPoint: 'search.ts', bundleName: 'search', include: ['/docs', '/docs/**'] },
// Posts, but not drafts
{
entryPoint: 'charts.ts',
bundleName: 'charts',
include: ['/blog/**'],
exclude: ['/blog/drafts/**'],
},
],
},
Each bundle is compiled from src/ and injected before </body> on the pages it matches, in this order.
- Patterns match the page's URL,
/docs/intro, not its file (site/docs/intro.mdordist/docs/intro.html). - A pattern has to match the whole URL, and
/docs/**doesn't match/docsitself, so list the index page on its own. *stays inside one folder and**crosses them. There are no braces: write/{docs,api}/**as two patterns.excludewins overinclude, and everybundleNamemust be unique.
The paths a page gets are in stati.assets.bundlePaths, handy for preloading:
<% for (const path of stati.assets?.bundlePaths ?? []) { %>
<link rel="modulepreload" href="<%= path %>">
<% } %>
In the Stati docs: Multiple bundles and Pattern matching.