Home > Web Front-end > JS Tutorial > Issues with wildcard support and dynamic file name generation when configuring Grunt's Task_javascript skills

Issues with wildcard support and dynamic file name generation when configuring Grunt's Task_javascript skills

WBOY
Release: 2016-05-16 15:40:27
Original
1408 people have browsed it
copy: { 
  // 这是Task里的其中一个Target 
  dests: { 
   expand: true, 
   cwd: '<%=config.app%>/newFolder', 
   src: ['**/{a*,b*}.html'], 
   dest: '<%=config.dist%>/newFolder', 
   ext: ".shtml", 
   extDot: "first", 
   flatten:true, //去掉中间上当,下面的rename可以再找回来 
   rename: function( dest, fileName ) { 
    return dest + "/" +fileName; 
   } 
  } 
 }
Copy after login

Wildcard support: supported by the node-glob library built into nodejs, these can be used in the various file configurations mentioned above

1. * matches any character except /

2. ? matches a single character, except /

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

4. "OR" operation separated by {} comma (no space after the comma)

5.! Exclude a match

Dynamicly generated file name:

Set expand to true to open the following options. If set to true, it means that the placeholders (i.e. * signs) in the following file names must be expanded into specific file names.

cwd All files specified by src are relative to the path specified by this attribute, and the directory where the file (input) that needs to be processed is located

src The path to be matched, relative to cwd, represents the file that needs to be processed. If it is in array form, each item in the array is a file name, and you can use the wildcard character

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

ext represents the processed file extension. Replace the suffix of all generated target files with this attribute

extDot:first: means starting from the first dot after the file name as the suffix; last: means starting from the last dot after the file name as the suffix

flatten: Delete the path part of all generated dest, the value is boolean type (true, false) used to specify whether to maintain the file directory structure, true is to maintain the file directory

rename is a function that accepts the matched file name and the matched target location, and returns a new target path

The above is what this article introduces to you about wildcard support and dynamic file name generation when configuring Grunt tasks. I hope it will be helpful to you.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template