【发布时间】:2017-12-14 16:20:07
【问题描述】:
我尝试将 scss 转换集成到我们现有的 maven 项目中。
我尝试添加
<plugin>
<groupId>nl.geodienstencentrum.maven</groupId>
<artifactId>sass-maven-plugin</artifactId>
<version>${maven.sass.plugin.version}</version>
<executions>
<execution>
<id>generate-css</id>
<phase>generate-resources</phase>
<goals>
<goal>update-stylesheets</goal>
</goals>
<configuration>
<sassOptions>
<always_update>true</always_update>
</sassOptions>
<includes>
<include>${scssSourceInclude}</include>
</includes>
<sassSourceDirectory>${project.basedir}/src/main/webapp/scss</sassSourceDirectory>
<destination>${project.build.directory}/${project.build.finalName}/css</destination>
<!-- <destination>${project.basedir}/src/main/webapp/css</destination> -->
</configuration>
</execution>
</executions>
</plugin>
当我运行 mvn clean install 命令时,它为设置为“目标”目录的目标正确编译:
[INFO] --- sass-maven-plugin:2.12:update-stylesheets (generate-css) @ ui.web ---
[INFO] Checked 1 files for d:\work\git\repository\project\src\main\webapp\scss
[INFO] Checked 0 files for d:\work\git\repository\project\target\ui.web\css
[INFO] Compiling Sass templates
[INFO] No resource element was specified, using short configuration.
[INFO] Queueing Sass template for compile: d:\work\git\repository\project/src/main/webapp/scss => d:\work\git\repository\project/target/ui.web/css
...
如果使用第二个(注释的)目的地,它会跳过 scss 编译:
[INFO] --- sass-maven-plugin:2.12:update-stylesheets (generate-css) @ ui.web ---
[INFO] Checked 1 files for d:\work\git\repository\project\src\main\webapp\scss
[INFO] Checked 959 files for d:\work\git\repository\project\src\main\webapp\css
[INFO] Skip compiling Sass templates, no changes.
唯一的区别是我需要在 src 目录中生成 css 文件,因为需要进一步处理(缩小、连接、添加许可证头等)
目录结构:
src
|-main
|-webapp
|-scss
|- common.scss
|- app.scss
|- admin
|- admin.scss
|-css
有人可以向我解释为什么这些文件没有被处理到 src 目录中吗?我应该应用一些缺少的配置吗?
【问题讨论】:
-
我也有类似的问题。我很想知道您是否找到了解决方案。
-
查看插件代码,似乎它正在比较源文件夹和目标文件夹以检查复制的 scss 文件或其他东西的差异(没有深入研究)——而不是找到任何因为它们是相同的文件夹/源文件。我在我的 css 文件夹中创建了一个“已编译”的子目录,并将其作为目标。它有效,所以这是我现在的解决方法。