Skip to content

Commit

Permalink
fix: Watch theme folders from Jar dependency (#11196) (#11262)
Browse files Browse the repository at this point in the history
Adds a reusable themes folders (both current or parent) 
coming from JAR dependencies to the webpack watch list.

Fixes #11152

Co-authored-by: Mikhail Shabarov <61410877+mshabarov@users.noreply.github.com>
  • Loading branch information
vaadin-bot and mshabarov committed Jun 17, 2021
1 parent f6c1809 commit df532b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,17 @@ function extractThemeName(frontendGeneratedFolder) {
}

/**
* Finds all the parent themes located in the project themes folders with
* respect to the given custom theme with {@code themeName}.
* Finds all the parent themes located in the project themes folders and in
* the JAR dependencies with respect to the given custom theme with
* {@code themeName}.
* @param {string} themeName given custom theme name to look parents for
* @param {object} options application theme plugin mandatory options,
* @see {@link ApplicationThemePlugin}
* @returns {string[]} array of paths to found parent themes with respect to the
* given custom theme
*/
function findParentThemes(themeName, options) {
const existingThemeFolders = options.themeProjectFolders.filter(
const existingThemeFolders = [options.themeResourceFolder, ...options.themeProjectFolders].filter(
(folder) => fs.existsSync(folder));
return collectParentThemes(themeName, existingThemeFolders, false);
}
Expand Down
9 changes: 5 additions & 4 deletions flow-server/src/main/resources/webpack.generated.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const projectStaticAssetsFolders = [
frontendFolder
];

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

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

...(devMode && themeName ? [new ExtraWatchWebpackPlugin({
files: [],
dirs: [...themeWatchFolders]
dirs: themeWatchFolders
}), new ThemeLiveReloadPlugin(processThemeResourcesCallback)] : []),

new StatsPlugin({
Expand Down

0 comments on commit df532b9

Please sign in to comment.