我目前正在使用 ruby gem SASS将我的 *.scss 文件转换为大型项目中的 *.css 文件。这是我正在使用的代码的模型:
<?xml version="1.0"?>
<!-- scss to CSS -->
<project name="StackOverflowScssCss" default="sass-compile-to-css" basedir=".">
<property file="build.properties" />
<target name="sass-compile-to-css">
<echo message="Compiling scss files to css..." />
<!-- create the css destination dir if it doesn't already exist -->
<property name="css-dest" location="${css.dir}" />
<echo message="Creating directory at ${css.dir} [if it doesn't yet exist]" />
<mkdir dir="${css-dest}" />
<!-- create subdirs if necessary -->
<echo message="Creating css directories (and temporary .css files) for .scss to be compiled..." />
<touch mkdirs="true">
<fileset dir="${sass.dir}" includes="**/*.scss" excludes="**/_*" />
<mapper type="glob" from="*.scss" to="${css.dir}/*.css" />
</touch>
<echo message="Running sass executable against sass files and compiling to CSS directory [${css-dest}] " />
<!-- run sass executable -->
<apply executable="sass" dest="${css-dest}" verbose="true" force="true" failonerror="true">
<arg value="--unix-newlines" />
<!-- Disable creation of map file. THIS SHOULD BE A FLAG -->
<arg value="--sourcemap=none" />
<srcfile />
<targetfile />
<fileset dir="${sass.dir}" includes="**/*.scss" excludes="**/_*" />
<mapper type="glob" from="*.scss" to="*.css" />
</apply>
<echo message="Done compiling scss files!" />
</target>
</project>
最终我想删除 ruby 依赖项,所以我一直在查看这个 libsass maven 插件。我知道libsass有很多选择,但我试图严格遵守 Java。有没有人有这样做的经验?我不想运行 Node.js、Sass.js 等任何东西,而且我整天都在绞尽脑汁思考如何做到这一点。任何帮助深表感谢!