是否可以在IntelliJ的编译期间引用webjar依赖项?想象一下,我正在玩一些CSS或HTML并进行一些调整..我不想清理 - >每次更改字体大小或颜色等时重建项目。我只想动态预览它们,在IntelliJ中。
假设您有webjars
Maven依赖项:
<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>
您可以通过在<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>
属性href
和src
将在编译时使用,而属性th:href
和th:scr
将由Thymeleaf在运行时使用。
以同样的方式,您可以使用自己的样式表或脚本:
<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>