Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: regenerate theme files if not existing during Vite resolution #14307

Merged
merged 1 commit into from Aug 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 12 additions & 6 deletions flow-server/src/main/resources/vite.generated.ts
Expand Up @@ -346,20 +346,26 @@ function themePlugin(opts): PluginOption {
handleHotUpdate(context) {
const contextPath = path.resolve(context.file);
const themePath = path.resolve(themeFolder);
// Track also updates on fronted/generated/theme.js to regenerate theme
// upon a java live reload when value of @Theme annotation changes.
const isThemeJS = contextPath === path.resolve(themeOptions.frontendGeneratedFolder, "theme.js");
if (isThemeJS || contextPath.startsWith(themePath)) {
if (contextPath.startsWith(themePath)) {
const changed = path.relative(themePath, contextPath);

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

if (isThemeJS || changed.startsWith(settings.themeName)) {
if (changed.startsWith(settings.themeName)) {
processThemeResources(fullThemeOptions, console);
}
}
},
async resolveId(id) {
async resolveId(id, importer) {
// force theme generation if generated theme sources does not yet exist
// this may happen for example during Java hot reload when updating
// @Theme annotation value
if (path.resolve(themeOptions.frontendGeneratedFolder, "theme.js") === importer &&
!existsSync(path.resolve(themeOptions.frontendGeneratedFolder, id))) {
console.debug('Generate theme file ' + id + ' not existing. Processing theme resource');
processThemeResources(fullThemeOptions, console);
return;
}
if (!id.startsWith(settings.themeFolder)) {
return;
}
Expand Down