Skip to content

Commit

Permalink
clean up plugin code
Browse files Browse the repository at this point in the history
  • Loading branch information
vursen committed Jan 23, 2025
1 parent bef6e12 commit 9406727
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions flow-server/src/main/resources/vite.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ function injectManifestToSWPlugin(): rollup.Plugin {
};
}

function buildSWPlugin(opts: { devMode: boolean }): PluginOption {
const { devMode } = opts;
function buildSWPlugin(): PluginOption {
let buildConfig: InlineConfig;

return {
Expand Down Expand Up @@ -149,20 +148,19 @@ function buildSWPlugin(opts: { devMode: boolean }): PluginOption {
},
},
},
plugins: [
!devMode && injectManifestToSWPlugin(),
!devMode && brotli()
]
};
},
async buildStart() {
if (devMode) {
if (buildConfig.mode === 'development') {
await build(buildConfig);
}
},
async closeBundle() {
if (!devMode) {
await build(buildConfig);
if (buildConfig.mode !== 'development') {
await build({
...buildConfig,
plugins: [injectManifestToSWPlugin(), brotli()]
});
}
},
};
Expand Down Expand Up @@ -727,7 +725,7 @@ export const vaadinConfig: UserConfigFn = (env) => {
productionMode && brotli(),
devMode && vaadinBundlesPlugin(),
devMode && showRecompileReason(),
settings.offlineEnabled && buildSWPlugin({ devMode }),
settings.offlineEnabled && buildSWPlugin(),
!devMode && statsExtracterPlugin(),
!productionMode && preserveUsageStats(),
themePlugin({ devMode }),
Expand Down

0 comments on commit 9406727

Please sign in to comment.