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 onwarn handler in svelte.config.js to filter warnings
  • Use environment variable like VERBOSE=1 pnpm build to toggle
  • Configure handleMissingId: 'ignore' in SvelteKit config for anchor warnings
  • Set compilerOptions.warningFilter in 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);
    }
};

Clean output

Less noise in build logs

A static site template built with SvelteKit.

Sveleton, 2025