I know it's a little late since the question was asked first, but I have had the same problem lately.
My answer is similar to the one suggested by Daniel Trebbien, but with slight modifications.
I do everything in the main class of this section because I have several sections in one project.
Initialize the variables first:
private final CssResource style; private final TextResource mobile;
In the resource class inside the main class:
@Source("main.css") CssResource style(); @Source("mobile.css") TextResource mobile();
Outside the resource class, but in the main class:
private void scheduleFinally() { StyleInjector.injectAtEnd("@media screen and (max-width:900px) {" + this.resources.mobile().getText() + "}"); }
Then I kind of “initialize” as css:
this.style = this.resources.style(); this.style.ensureInjected(); this.mobile = this.resources.mobile(); scheduleFinally();
source share