diff --git a/vite.config.ts b/vite.config.ts index d3080a5d12b..53717813a10 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -38,10 +38,25 @@ const webComponents = new Set([ 'text-expander', ]); +function failOnWarningsPlugin(): Rolldown.Plugin { + let warningCount = 0; + return { + name: 'fail-on-warnings', + onLog(level) { + if (level === 'warn') warningCount++; + }, + buildEnd() { + if (!warningCount) return; + throw new Error(`${warningCount} warnings present`); + }, + }; +} + const commonRolldownOptions: Rolldown.RolldownOptions = { checks: { pluginTimings: false, }, + ...(env.CI ? {plugins: [failOnWarningsPlugin()]} : {}), }; function commonViteOpts({build, ...other}: InlineConfig): InlineConfig {