使用ANT构建任务将SASS编译为CSS

时间:2013-05-01 09:19:02

标签: css ant build sass

我已成功地使用build.xml文件中的以下脚本将我的SASS编译为CSS

<apply executable="sass.bat" dest="${css.dir}" verbose="true" force="true" failonerror="true">
    <arg value="--unix-newline" />
    <srcfile />
    <targetfile />
    <fileset dir="${sass.dir}" includes="**/*.scss,**/*.sass" excludes="**/_*" />
    <firstmatchmapper>
      <globmapper from="*.sass" to="*.css" />
      <globmapper from="*.scss" to="*.css" />
    </firstmatchmapper>
  </apply>
  <echo message="Done compiling scss files!" />
</target>

如何将SASS选项作为参数传递?例如,我想将SASS编译为--style:压缩状态

2 个答案:

答案 0 :(得分:2)

您已经将参数传递给sass.bat。见行

<arg value="--unix-newlines" />

您可以根据需要添加任意数量的arg元素。

请参阅http://ant.apache.org/manual/using.html#arg

答案 1 :(得分:1)

<arg value="--unix-newlines" />

会奏效。编译器的其他命令行参数也是如此,只要将它们包含为单独的“arg”s

即可