Skip to content

Commit 7b64c96

Browse files
fix: let Vite process theme also on theme.js changes (#14257) (#14258)
Flow theme plugin for Vite processes themes only on changes on files in active theme directory. This preventes regeneration with java live reload when changing value of Theme annotation. This change triggers theme processing also for updates on theme.js file. Co-authored-by: Marco Collovati <marco@vaadin.com>
1 parent 52d45eb commit 7b64c96

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎flow-server/src/main/resources/vite.generated.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,12 +334,15 @@ function themePlugin(opts): PluginOption {
334334
handleHotUpdate(context) {
335335
const contextPath = path.resolve(context.file);
336336
const themePath = path.resolve(themeFolder);
337-
if (contextPath.startsWith(themePath)) {
337+
// Track also updates on fronted/generated/theme.js to regenerate theme
338+
// upon a java live reload when value of @Theme annotation changes.
339+
const isThemeJS = contextPath === path.resolve(themeOptions.frontendGeneratedFolder, "theme.js");
340+
if (isThemeJS || contextPath.startsWith(themePath)) {
338341
const changed = path.relative(themePath, contextPath);
339342

340343
console.debug('Theme file changed', changed);
341344

342-
if (changed.startsWith(settings.themeName)) {
345+
if (isThemeJS || changed.startsWith(settings.themeName)) {
343346
processThemeResources(fullThemeOptions, console);
344347
}
345348
}

0 commit comments

Comments
 (0)