Is it possible to reference webjar dependencies during compile time in IntelliJ? Imagine I'm playing with some CSS or HTML and making some little adjustments.. I don't want to clean -> rebuild project each time I change font-size or color or etc. I just want to preview them on the fly, in IntelliJ.
Assuming you have webjars
Maven dependencies:
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>${bootstrap.version}</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>${jquery.version}</version>
</dependency>
You could refer to your resources by putting the following code in your templates within <head></head>
:
<link href="webjars/bootstrap/3.3.7-1/css/bootstrap.min.css" rel="stylesheet" media="screen"
th:href="@{/webjars/bootstrap/3.3.7-1/css/bootstrap.min.css}"/>
<script src="webjars/jquery/3.2.0/jquery.min.js"
th:src="@{/webjars/jquery/3.2.0/jquery.min.js}"></script>
Attributes href
and src
will be used in compile time, while attributes th:href
and th:scr
would be used by Thymeleaf in run time.
In the same way you could use your own stylesheets or scripts:
<link href="../../static/css/app.css" th:href="@{css/app.css}" rel="stylesheet" media="screen"/>
<script src="../../static/js/app.js" th:src="@{js/app.js}"></script>