1

ビルド スクリプトを実行するときにファイルから削除したい変数セクションを含む css ファイルがあります (ただし、ソース内のセクションを保持する必要があります)。セクションをコメント (/* remove-front / & / remove-back */) でラップし、ある種のトークンを使用してから、ant を使用してコメント間のすべてを何も置き換えないと考えています。

これが私の例です:

/* remove-front */
.footerGradients {
  /* gradient settings (used http://www.colorzilla.com/gradient-editor/ to generate following code) */

  background-color: #606869;
  background: -webkit-gradient(linear, left bottom, left top, color-stop(0, #2f3838), color-stop(100%, #606869));
  background: -moz-linear-gradient(center bottom, #2f3838 0, #606869 100%);
  background: -ms-linear-gradient(center bottom, #2f3838 0, #606869 100%);
  background: -o-linear-gradient(center bottom, #2f3838 0, #606869 100%);
  background: linear-gradient(center bottom, #2f3838 0, #606869 100%);
  -pie-background: linear-gradient(#2f3838, #606869);
  filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#2f3838,endColorstr=#606869);
  /* end gradient settings */

}
.footerShadows {
  /* box shadow settings (used http://css3generator.com/ to generate following code) */

  -webkit-box-shadow: 0 0 2px 0 #293535;
  -moz-box-shadow: 0 0 2px 0 #293535;
  box-shadow: 0 0 2px 0 #293535;
  /* end box shadow settings */

}
/* remove-back */

ご回答ありがとうございます。

4

2 に答える 2

1

私は @FailedDev と同じ考えを持っていましたが、Eclipse を試してみると、「m」オプションに悩まされていました (そして、/*remove-front */(スペース) と/*REMOVE-BACK*/(大文字と小文字を区別しない) を使用する機能を追加しました):

<copy tofile="src/test2.css" file="src/test.css" overwrite="true"/>
<replaceregexp 
   file="src/test2.css" 
   match="/\*\s*remove-front\s*\*/.*?/\*\s*remove-back\s*\*/"
   replace=""
   flags="gsi" 
   byline="false"/>
于 2011-10-05T23:28:47.377 に答える
0

標準の replaceregexp タスクを使用します。

http://ant.apache.org/manual/Tasks/replaceregexp.html

 <replaceregexp file="${css.file}"
                match="/\* remove-front \*/.*?/\* remove-back \*/"
                replace=""
                byline="false"
                flags="gs"
/>
于 2011-10-05T23:20:53.423 に答える