java - 将 autoprefix-cli 添加到 ANT 构建

标签 java css build ant autoprefixer

我正在尝试添加 autoprefix-cli到我的 ANT 版本。下面是我的代码。

<target name="auto">
<apply executable="autoprefixer-cli.bat" verbose="true" force="true" failonerror="true">
    <arg value="-d" /> <!-- Turn on verbose -->
    <arg value="prefix" />
    <arg value="*.css" />  
</apply>
</target>

当我进行 ant 构建时,它会提示我未指定资源的错误。

BUILD FAILED
D:\tempTest\AntTestProject\build.xml:25: no resources specified

注意:我可以从命令行访问 autoprefix-cli,它使用 -g 标志安装,并且当我直接从命令行使用它时它也可以工作。

最佳答案

apply 任务基本上是在一批资源(文件、目录、URL 等)上循环执行 exec 任务。如果您只想运行一个命令,请改用 exec

但是,您可能还需要更改您的命令。来自 Ant 的 exec 任务文档:

Note that .bat files cannot in general by executed directly. One normally needs to execute the command shell executable cmd using the /c switch.

https://ant.apache.org/manual/Tasks/exec.html

所以你应该:

<exec executable="cmd" verbose="true" force="true" failonerror="true">
    <arg value="/c" />
    <arg value="autoprefixer-cli.bat" />
    <arg value="-d" />
    <arg value="prefix" />
    <arg value="*.css" />  
</exec>

关于java - 将 autoprefix-cli 添加到 ANT 构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48547704/

相关文章:

CSS Sprite 和 anchor

javascript - 修复 jQuery 下拉列表中的宽度

javascript - 如何从基于模板的网站打印条形码?

c - 将 pg_config 与 waf 一起使用

java - Hibernate @SecondaryTable - 指定主表的外键

java - CustomArrayAdapter android 空指针异常

java - 删除文本时如何隐藏 Eclipse 中的建议框?

java - 我知道 HashSet 内部工作方式与 HashMap 和 HashMap 内部工作方式相同

c++ - 使用 Cmake 和 MinGW 编译 OpenCV 2.4.13

amazon-web-services - 将 VSTS Build 与 AWS 结合使用的最简单方法是什么?