Skip to content

Commit

Permalink
fix: Watch theme folders from Jar dependency (#11196) (#11264) (#11276)
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>

Co-authored-by: caalador <mikael.grankvist@vaadin.com>
Co-authored-by: Mikhail Shabarov <61410877+mshabarov@users.noreply.github.com>
  • Loading branch information
3 people committed Jun 17, 2021
1 parent 23ce4fc commit 2ffe00f
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(themeFolder) {
}

/**
* 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 @@ -47,7 +47,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 @@ -110,8 +110,9 @@ if (devMode) {
// target/frontend/themes folder
themeName = extractThemeName(flowFrontendThemesFolder);
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 @@ -279,7 +280,7 @@ module.exports = {

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

new StatsPlugin({
Expand Down

0 comments on commit 2ffe00f

Please sign in to comment.