开发者

Concatenating CSS files in a specific order

开发者 https://www.devze.com 2023-03-18 06:44 出处:网络
I have a series of CSS files that I am concatenating and minfying (using the YUI Compressor) with an Ant build script.The CSS files are:

I have a series of CSS files that I am concatenating and minfying (using the YUI Compressor) with an Ant build script. The CSS files are:

  • Reset.css
  • Formalize.css
  • Typography.css
  • Site.css

There are other CSS files like ie.css and ed开发者_JAVA技巧itor.css that I don't want to include in the minification. I have my build script working with the following code, but the problem now is that the files need to be concatenated in the order posted above.

<target name="minifycss">
    <!-- Combine all CSS files except for ones specified for IE or the content editor -->
    <concat destfile="css/e123-1.css">
        <fileset dir="css" includes="*.css" excludes="ie.css editor.css print.css" />
    </concat>

    <!-- Minify the css -->
    <java fork="true" jar="${yuicompressor.lib}" dir="css" output="css/e123-1.min.css">
        <arg value="e123-1.css" />
    </java>
</target>

I assume that the files are added alphabetically, but I was wondering if there was a way to tell Ant what order to concatenate the files without renaming them to 1reset.css, 2formalize.css, etc.


Use a filelist, as shown in the ant concat documentation.


If using wro4j, you can control the order of the resources to concatenate like this:

      <groups>
         <group name="all">
           <css>/static/reset.css</css>
           <css>/static/fonts.css</css>
           <css>/wildcard/*.css</css>
           <js>/static/js/lib/core.js</js>
         </group>
      </groups>

It allows you to use wildcards and also can be used for javascript resources (not only css)

This is a biased answer, because i'm working on wro4j project.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号