Skip to content

Commit c489db4

Browse files
silverwindclaudebircni
authored
Fail vite build on rolldown warnings via NODE_ENV=test (#37270)
Fail the vite build on any rolldown warnings when `NODE_ENV=test` is set. This gate is set on the CI `make frontend` steps (compliance and e2e workflows) and on the local `make test-e2e` target, so warnings fail the build both in CI and when running e2e tests locally. Regular `make frontend` / production builds are unaffected. Example output: ``` [plugin test-warning-injector] first synthetic warning [plugin test-warning-injector] second synthetic warning transforming...✗ Build failed in 14ms error during build: Build failed with 1 error: [plugin fail-on-warnings] Error: 2 warnings present at PluginContextImpl.buildEnd (vite.config.ts:50:13) ... ``` --- This PR was written with the help of Claude Opus 4.7 --------- Signed-off-by: silverwind <me@silverwind.io> Co-authored-by: Claude (Opus 4.7) <noreply@anthropic.com> Co-authored-by: Nicolas <bircni@icloud.com>
1 parent 38d337c commit c489db4

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

vite.config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,25 @@ const webComponents = new Set([
3838
'text-expander',
3939
]);
4040

41+
function failOnWarningsPlugin(): Rolldown.Plugin {
42+
let warningCount = 0;
43+
return {
44+
name: 'fail-on-warnings',
45+
onLog(level) {
46+
if (level === 'warn') warningCount++;
47+
},
48+
buildEnd() {
49+
if (!warningCount) return;
50+
throw new Error(`${warningCount} warnings present`);
51+
},
52+
};
53+
}
54+
4155
const commonRolldownOptions: Rolldown.RolldownOptions = {
4256
checks: {
4357
pluginTimings: false,
4458
},
59+
...(env.CI ? {plugins: [failOnWarningsPlugin()]} : {}),
4560
};
4661

4762
function commonViteOpts({build, ...other}: InlineConfig): InlineConfig {

0 commit comments

Comments
 (0)