Support for wildcards and dynamic file name generation When configuring Grunt tasks, grunttask

Source: Internet
Author: User

Support for wildcards and dynamic file name generation When configuring Grunt tasks, grunttask

Copy: {// This is one of the Target dests: {expand: true, cwd: '<% = config. app %>/newFolder ', src: [' **/{a *, B * }.html '], dest:' <% = config. dist %>/newFolder ', ext :". shtml ", extDot:" first ", flatten: true, // remove the intermediate form. The following rename can be returned: rename: function (dest, fileName) {return dest + "/" + fileName ;}}}

Wildcard support: supported by the node-glob library built in node. js. These can be used in the various file configurations mentioned above.

1. * match any character/

2 ,? Match a single character,/

3. ** match any character, including/, so it is used in the directory path.

4. {} comma-separated "or" Operation (do not include spaces after the comma)

5 ,! Exclude a match

Dynamic file name generation:

If expand is set to true, the following option is enabled. If it is set to true, The placeholder (I .e., the *) of the following file name must be expanded to a specific file name.

The Directory of the file (input) to be processed relative to the path specified by this property for all src files in cwd

The path to be matched by src. Relative to cwd, it indicates the file to be processed. If an array is used, each item of the array is a file name. Wildcards can be used.

The destination path prefix generated by dest, indicating the processed file name or object

Ext indicates the suffix of the processed file. Replace the suffix of all generated target files with this attribute.

ExtDot: first: start after the first vertex after the file name as the suffix; last: start after the last vertex after the file name as the suffix name

Flatten: delete all generated dest path parts. The value is boolean (true or false) to specify whether to maintain the file directory structure. true indicates to keep the file directory.

Rename a function that accepts the matched file name and matches the target location and returns a new target path.

The above is the wildcard support for configuring Grunt tasks and dynamically generating file names.

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.