Reduce build logging
1 minute read
The build output is very verbose with many warnings. Add a way to toggle detailed logging.
Current Warnings
- Svelte a11y warnings (media captions, click handlers, etc.)
- State referenced locally warnings
- Missing anchor ID warnings from prerender
- CSS syntax warnings
- Component naming warnings
Solution
Options to reduce logging:
- Add
onwarnhandler insvelte.config.jsto filter warnings - Use environment variable like
VERBOSE=1 pnpm buildto toggle - Configure
handleMissingId: 'ignore'in SvelteKit config for anchor warnings - Set
compilerOptions.warningFilterin svelte.config.js
Example
// svelte.config.js
const config = {
onwarn: (warning, handler) => {
if (process.env.VERBOSE) {
handler(warning);
} else if (warning.code === 'a11y_media_has_caption') return;
else if (warning.code === 'state_referenced_locally') return;
else handler(warning);
}
}; Read next