7

我在 src/main/webapp/VAADIN/themes/mytheme/ 中有我的 VAADIN 应用程序的自定义主题,其中包含文件 mytheme.scss 和 styles.scss。当 web.xml 中的 vaadin productionMode 部署参数设置为 false 时,一切正常。当我将参数设置为 true 时,突然 Vaadin 找不到我的主题的资源并不断抱怨:

Requested resource [/VAADIN/themes/mytheme/styles.css] not found from filesystem or through class loader. Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder

我没有 /WebContent 目录,而是 /webapp,因为它是一个 maven web-app 项目。我尝试将 VAADIN 文件夹放到:
src/main/resources
src/main/webapp
src/main/webapp/WEB-INF

但对生产模式没有任何作用。有什么建议吗?提前感谢您的帮助。

4

3 回答 3

15

您需要在 pom.xml 中添加以下目标,这会将 .scss 文件编译为 .css 文件:

<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>

来源:http ://dev.vaadin.com/ticket/10291

于 2013-05-15T11:24:28.057 回答
3

@Develman 已经回答了如何解决这个问题,但还有更多解释。

当 Vaadin 应用程序处于开发模式时,它会在请求 styles.css 且文件不存在时自动进行 SCSS -> CSS 编译。在生产模式下,这不会发生。如果styles.css 存在,无论模式如何,都使用该文件并且没有SCSS -> CSS 编译。

于 2013-05-15T15:05:16.840 回答
1

即使我在 pom.xml 中添加了 maven 目标,我也得到了这个错误终于知道了原因,这是因为我在 web.xml 上启用了 Vaadin 的生产模式所以当生产模式打开时,它不会生成样式。 css 文件。因此,您需要禁用生产模式才能启用此 SCSS -> CSS 编译。

<context-param>
    <description>Vaadin production mode</description>
    <param-name>productionMode</param-name>
    <param-value>false</param-value>
</context-param>
于 2014-08-30T16:23:08.467 回答