Configure Grunt task-time wildcard support and dynamically generate file name problems _javascript tips

Source: Internet
Author: User
Copy: { 
  //This is one of the target dests in the task 
  : { 
   expand:true, 
   cwd: ' <%=config.app%>/newfolder ', 
   SRC: [' **/{a*,b*}.html '], 
   dest: ' <%=config.dist%>/newfolder ', 
   ext: ". shtml", 
   Extdot: "A", 
   flatten:true,//get rid of the middle fooled, the following rename can be found again 
   rename:function (dest, fileName) {return 
    dest + "/" +filename;< c12/>}}} 
 

Wildcard support: Supported by the Nodejs built-in Node-glob library, which can be used in the various file configurations described above

1, * match any character, in addition to/

2. Match a single character, except/

3, * * matches any character, including/, so used in the directory path

4, {} comma-separated "or" action (no spaces after commas)

5,! Exclude a match

Dynamically generate file name:

Expand set to True open the following options, if set to true, to indicate that the following file name placeholder (that is, *) is extended to a specific file name.

CWD the directory where all SRC-specified files are specified relative to this property, and the files (input) that need to be processed

SRC to match the path, relative to the CWD, represents the file that needs to be processed. If you take an array, each item in the array is a filename, and you can use the wildcard character

Dest the generated target path prefix that represents the processed file name or destination

Ext represents the file suffix name after processing. Replace all generated target file suffixes with this property

Extdot:first: Indicates that the suffix name begins after the first point after the filename; Last: Indicates that the suffix name starts after the final point after the filename

Flatten: Deletes the path portion of all generated dest, the value is Boolean (True, false) to specify whether to keep the file directory structure, true is to keep the file directory

Rename a function that accepts a matching file name and matches the target location, returning a new target path

The above is the introduction of this article in the configuration of the task of grunt wildcard support and dynamic generation of file names, I hope to help.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.