mirror of
https://github.com/go-gitea/gitea.git
synced 2026-04-26 15:54:35 +00:00
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>
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user