如何使用Vaadin 7和Maven编译其他非主题SCSS文件

问题描述

在Vaadin 7的CustomComponent中,我们具有注释:

@StyleSheet({"../../VAADIN/themes/mytheme/views/someView.css"})

productionModefalse时,效果很好。

有问题的文件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>