Jas*_*ske 14
我认为你要找的是一个Servlet过滤器.我是不知道的一个现成的一个没有LESS编译,并会已经开始使用,使一个lesscss-java的,但现在我可以看到有一个叫大项目的Web资源优化的Java - wro4j与服务器端的支持较少.
在构建Web应用程序期间,首先将较少的文件编译为css文件会更简单(也更有效).
例如,当使用Maven时,我们使用lesscss-maven-plugin(编译目标,进程源阶段)从较少的文件生成css文件.然后只在webapp中使用和打包css文件.没有少的文件都是动态的.
另一个优点是在部署webapp之前编译的文件较少,因此可以更快地检测到编译错误.
pom.xml中的配置示例:
<plugin>
<groupId>org.lesscss</groupId>
<artifactId>lesscss-maven-plugin</artifactId>
<version>1.3.0</version>
<configuration>
<sourceDirectory>${project.basedir}/src/main/webapp/less</sourceDirectory>
<outputDirectory>${project.build.directory}/${project.build.finalName}/css</outputDirectory>
<compress>true</compress>
<includes>
<include>main.less</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
小智 5
我们所做的是有两种模式:开发和生产.
对于dev,使用官方的less css js编译器,它可以动态编译:
<link type="text/css" rel="stylesheet/less" href="${...}/style.less" />
<script>(window.less = window.less || {}).env = 'development';</script>
<script src="${staticContext}/lib/less-1.3.3.js"></script>
Run Code Online (Sandbox Code Playgroud)
在你的HTML中
对于prod,请使用https://github.com/marceloverdijk/lesscss-maven-plugin编译的样式
<link type="text/css" rel="stylesheet" href="${staticContext}/css/style.css" />
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6357 次 |
最近记录: |