我正在使用grunt-babel将 ES6 转换为 ES5。我的文件名之一是 app.collection.js ,运行任务后,将其重命名为 app.js 。
babel option是什么?来解决这个问题。
/****************************************************************************
* Grunt Babel Compile ES6 to ES5
****************************************************************************/
babel: {
options: {
blacklist: ['strict'],
comments: true,
loose: ["es6.classes", "es6.properties.computed"],
"ignore": [
]
},
dist: {
files: [{ // Dictionary of files
expand: true,
cwd: '<%= config.path.app.js %>',
src: ['**/**/*.js'],
dest: '<%= config.path.app.js %>',
ext: '.js'
}]
}
}
最佳答案
您可以完全删除 ext
属性,也可以添加值为最后的 extDot
属性以保留 app.collection.js
名称。
files: [{ // Dictionary of files
expand: true,
cwd: '<%= config.path.app.js %>',
src: ['**/**/*.js'],
dest: '<%= config.path.app.js %>',
ext: '.js',
extDot: 'last'
}]
查看更多信息 Building the files object dynamically @ gruntjs.com
extDot
Used to indicate where the period indicating the extension is located. Can take either 'first' (extension begins after the first period in the file name) or 'last' (extension begins after the last period), and is set by default to 'first' [Added in 0.4.3]
关于gruntjs - 保持点分隔文件 grunt-babel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31666530/