Skip to content

Commit 7401a5a

Browse files
authored
fix: Watch theme folders from Jar dependency (#11196)
Adds a reusable themes folders (both current or parent) coming from JAR dependencies to the webpack watch list. Fixes #11152
1 parent 108ce47 commit 7401a5a

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

‎flow-server/src/main/resources/plugins/application-theme-plugin/theme-handle.js‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,17 @@ function extractThemeName(frontendGeneratedFolder) {
198198
}
199199

200200
/**
201-
* Finds all the parent themes located in the project themes folders with
202-
* respect to the given custom theme with {@code themeName}.
201+
* Finds all the parent themes located in the project themes folders and in
202+
* the JAR dependencies with respect to the given custom theme with
203+
* {@code themeName}.
203204
* @param {string} themeName given custom theme name to look parents for
204205
* @param {object} options application theme plugin mandatory options,
205206
* @see {@link ApplicationThemePlugin}
206207
* @returns {string[]} array of paths to found parent themes with respect to the
207208
* given custom theme
208209
*/
209210
function findParentThemes(themeName, options) {
210-
const existingThemeFolders = options.themeProjectFolders.filter(
211+
const existingThemeFolders = [options.themeResourceFolder, ...options.themeProjectFolders].filter(
211212
(folder) => fs.existsSync(folder));
212213
return collectParentThemes(themeName, existingThemeFolders, false);
213214
}

‎flow-server/src/main/resources/webpack.generated.js‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const projectStaticAssetsFolders = [
6161
frontendFolder
6262
];
6363

64-
const projectStaticAssetsOutputFolder = [to-be-generated-by-flow];
64+
const projectStaticAssetsOutputFolder = '[to-be-generated-by-flow]';
6565

6666
// Folders in the project which can contain application themes
6767
const themeProjectFolders = projectStaticAssetsFolders.map((folder) =>
@@ -187,8 +187,9 @@ if (devMode) {
187187
// generated folder
188188
themeName = extractThemeName(frontendGeneratedFolder);
189189
const parentThemePaths = findParentThemes(themeName, themeOptions);
190-
const currentThemeFolders = projectStaticAssetsFolders
191-
.map((folder) => path.resolve(folder, "themes", themeName));
190+
const currentThemeFolders = [...projectStaticAssetsFolders
191+
.map((folder) => path.resolve(folder, "themes", themeName)),
192+
path.resolve(flowFrontendThemesFolder, themeName)];
192193
// Watch the components folders for component styles update in both
193194
// current theme and parent themes. Other folders or CSS files except
194195
// 'styles.css' should be referenced from `styles.css` anyway, so no need
@@ -330,7 +331,7 @@ module.exports = {
330331

331332
...(devMode && themeName ? [new ExtraWatchWebpackPlugin({
332333
files: [],
333-
dirs: [...themeWatchFolders]
334+
dirs: themeWatchFolders
334335
}), new ThemeLiveReloadPlugin(processThemeResourcesCallback)] : []),
335336

336337
new StatsPlugin({

0 commit comments

Comments
 (0)