简体   繁体   English

使用带有咕噜声的babel递归地将ES6转换为ES5

[英]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 the foo/ subdirectory, but foo/**/*.js will match all files ending with .js in the foo/ 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM