Skip to content

feat: Serve theme files separately from dev bundle - #15518

Merged
mshabarov merged 15 commits into
masterfrom
handle-styles-css-separately
Dec 21, 2022
Merged

mshabarov merged 15 commits into
masterfrom
handle-styles-css-separately

Conversation

@mshabarov

@mshabarov mshabarov commented Dec 16, 2022 •

Copy link
Copy Markdown
Contributor

In the Express Build mode:

  • serves theme files (styles.css and other project's stylesheets imported to styles.css) separately from the dev-bundle directly from custom theme (frontend/themes/my-theme) folder
  • copies the assets referenced in theme.json to the dev bundle within bundle re-compilation
  • serves assets/styles from dev-bundle, if can't find them in the frontend folder

Does not yet take into account serving styles from default bundle (from classpath).

Related-to #15478

@github-actions

github-actions Bot commented Dec 16, 2022 •

Copy link
Copy Markdown
Contributor

Test Results

   930 files  +1     930 suites  +1   50m 16s ⏱️ + 1m 57s
5 833 tests +5  5 798 ✔️ +5  35 💤 ±0  0 ❌ ±0 
6 087 runs  +7  6 045 ✔️ +7  42 💤 ±0  0 ❌ ±0 

Results for commit 8f14d03. ± Comparison against base commit 96958bb.

♻️ This comment has been updated with latest results.

// First, look for the theme assets in the {project.root}/frontend/
// themes/my-theme folder
File frontendFolder = new File(projectFolder, FrontendUtils.FRONTEND);
File assetInFrontendThemes = new File(frontendFolder, assetPath);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

13% of developers fix this issue

PATH_TRAVERSAL_IN: This API (java/io/File.(Ljava/io/File;Ljava/lang/String;)V) reads a file whose location might be specified by user input


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

…eparately

# Conflicts:
#	flow-server/src/main/java/com/vaadin/flow/server/communication/IndexHtmlRequestHandler.java
@mshabarov
mshabarov force-pushed the handle-styles-css-separately branch from e86c05c to 7412d6b Compare December 19, 2022 07:30
@vaadin-bot vaadin-bot added +0.0.1 and removed +1.0.0 labels Dec 19, 2022
@vaadin-bot vaadin-bot added +1.0.0 and removed +0.0.1 labels Dec 19, 2022
…eparately

# Conflicts:
#	flow-server/src/test/java/com/vaadin/flow/server/communication/IndexHtmlRequestHandlerTest.java
@mshabarov
mshabarov force-pushed the handle-styles-css-separately branch from d279f55 to 760a6d6 Compare December 20, 2022 07:07
@vaadin-bot vaadin-bot added +0.0.1 and removed +1.0.0 labels Dec 20, 2022
@mshabarov
mshabarov marked this pull request as ready for review December 20, 2022 14:00
@mshabarov
mshabarov requested review from Artur- and caalador December 20, 2022 14:02
},
build: {
outDir: buildOutputFolder,
emptyOutDir: devBundle,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've commented it when was developing the feature, because if it's set to true the assets copied from node_modules to the dev-bundle was removed immediately. So it was copied and removed. I'll double check it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like themePlugin({devMode}), which copies the assets to the dev-bundle is executed before the Vite empties the bundle output folder. An easiest way to fix it is probably to copy assets into dev-bundle/assets, not inside the bundle output dir dev-bundle/webapp/assets.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks for noticing this 👍

@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@mshabarov
mshabarov merged commit e8cf52e into master Dec 21, 2022
@mshabarov
mshabarov deleted the handle-styles-css-separately branch December 21, 2022 12:04
MarcinVaadin pushed a commit that referenced this pull request Dec 21, 2022
In the Express Build mode:

- serves theme files (styles.css and other project's stylesheets imported to styles.css) separately from the dev-bundle directly from custom theme (frontend/themes/my-theme) folder
- copies the assets referenced in theme.json to the dev bundle within bundle re-compilation
serves assets/styles from dev-bundle, if can't find them in the frontend folder
- Does not yet take into account serving styles from default bundle (from classpath).

Related-to #15478
@vaadin-bot

Copy link
Copy Markdown
Collaborator

This ticket/PR has been released with Vaadin 24.0.0.alpha7 and is also targeting the upcoming stable 24.0.0 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants