[英]Recursively convert ES6 to ES5 using babel with grunt
My grunt file is as follows : 我的grunt文件如下:
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: {
js: ['src/*.min.js']
},
babel: {
files: {
expand: true,
src: ['src/*.js','src/*/*.js','src/*/*/*.js'],
ext: '-modified.js'
},
options: {
sourceMap: false,
presets: ['babel-preset-es2015']
}
},
watch: {
tasks: ['babel']
}
});
grunt.registerTask('default', ['clean','babel']);
};
Is there a better way to configure "src" this so that it would recursively find out the js file within src folder and subfolders and transpile those file: 有没有更好的方法来配置“src”这样,它将递归地找出src文件夹和子文件夹中的js文件并转换这些文件:
src: ['src/*.js','src/*/*.js','src/*/*/*.js']
Those three globbing patterns: 那三个全球模式:
src: ['src/*.js','src/*/*.js','src/*/*/*.js']
...can be replaced with one: ......可以换成一个:
src: ['src/**/*.js']
See the text that reads: 见文字:
All most people need to know is that
foo/*.js
will match all files ending with.js
in thefoo/
subdirectory, butfoo/**/*.js
will match all files ending with.js
in thefoo/
subdirectory and all of its subdirectories.所有大多数人都需要知道的是
foo/*.js
.js
将匹配foo/
子目录中以.js
结尾的所有文件,但是foo/**/*.js
.js
将匹配foo/
子目录中以.js
结尾的所有文件foo/**/*.js
它的所有子目录。
... in the Globbing patterns of the grunt documentation. ...在grunt文档的Globbing模式中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.