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

Java-side resource is not available if resource not referenced in a CSS file #9622

Closed
mshabarov opened this issue Dec 9, 2020 · 1 comment · Fixed by #9776
Closed

Java-side resource is not available if resource not referenced in a CSS file #9622

mshabarov opened this issue Dec 9, 2020 · 1 comment · Fixed by #9776

Comments

@mshabarov
Copy link
Contributor

Changing the style on java side, like below

getElement().getStyle().set("background-image",
                "url('theme/my-theme/images/background.jpg')");

does not work if the resource (background.jpg in our case) is not mentioned in any CSS file within /theme/my-theme/ folder. But it does work, if adding the reference to that resource (whatever the target element is), for example:

.some-target {
    background: url("./images/background.jpg");
}

It impacts both the dev and production mode.

@caalador caalador changed the title Java-side style is not applied if no resource reference in CSS file Java-side resource is not available if resource not referenced in a CSS file Dec 11, 2020
@caalador
Copy link
Contributor

Here we should not that we should only copy files that are not handled by webpack through the file-loader.
This is especially a challenge in development mode where the files are not copied to the disk, but are served by the running devServer.

@mshabarov mshabarov self-assigned this Jan 5, 2021
@pleku pleku added this to the Custom Theme Feature milestone Jan 11, 2021
caalador pushed a commit that referenced this issue Jan 12, 2021
#9776)

Copies static resources from theme folder to a webpack output folder, so that to make them available from Java pages.

Fixes: #9622
caalador pushed a commit that referenced this issue Mar 10, 2021
#9776)

Copies static resources from theme folder to a webpack output folder, so that to make them available from Java pages.

Fixes: #9622
# Conflicts:
#	flow-server/src/main/resources/plugins/application-theme-plugin/theme-copy.js
#	flow-tests/test-themes/frontend/themes/app-theme/styles.css
#	flow-tests/test-themes/src/test/java/com/vaadin/flow/uitest/ui/theme/ThemeIT.java
pleku pushed a commit that referenced this issue Mar 12, 2021
#9776)

Copies static resources from theme folder to a webpack output folder, so that to make them available from Java pages.

Fixes: #9622
# Conflicts:
#	flow-server/src/main/resources/plugins/application-theme-plugin/theme-copy.js
#	flow-tests/test-themes/frontend/themes/app-theme/styles.css
#	flow-tests/test-themes/src/test/java/com/vaadin/flow/uitest/ui/theme/ThemeIT.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment