问题描述
在Vaadin 7的CustomComponent
中,我们具有注释:
@StyleSheet({"../../VAADIN/themes/mytheme/views/someView.css"})
当productionMode
为false
时,效果很好。
有问题的文件是styles.scss
未引用的独立样式表
但是,一旦将productionMode
设置为true
,Vaadin便不会在运行时编译相应的.scss
,这是预期的行为。
我知道有一个com.vaadin.sass.SassCompiler
,但是我找不到如何与maven一起使用的文档,因此在构建过程中会编译非主题的.scss
。
下面是vaadin-maven-plugin
的用法:
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>7.7.13</version>
<configuration>
<extraJvmArgs>-Xmx1024M -Xss2048k</extraJvmArgs>
<noServer>true</noServer>
<webappDirectory>${basedir}/src/main/webapp/VAADIN/widgetsets</webappDirectory>
<compileReport>false</compileReport>
<style>OBF</style>
<strict>true</strict>
</configuration>
<executions>
<execution>
<configuration>
<!-- if you don't specify any modules,the plugin will find them -->
<!-- <modules> <module>com.vaadin.demo.mobilemail.gwt.ColorPickerWidgetSet</module>
</modules> -->
</configuration>
<goals>
<goal>resources</goal>
<goal>compile</goal>
<goal>compile-theme</goal>
<goal>update-theme</goal>
</goals>
</execution>
</executions>
</plugin>
解决方法
正确答案在:
https://stackoverflow.com/a/16563759/184201
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<classpathScope>compile</classpathScope>
<mainClass>com.vaadin.sass.SassCompiler</mainClass>
<arguments>
<argument>src/main/webapp/VAADIN/themes/heijunka/styles.scss</argument>
<argument>src/main/webapp/VAADIN/themes/heijunka/styles.css</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>