gruntjs - 保持点分隔文件 grunt-babel

标签 gruntjs babeljs

我正在使用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/

相关文章:

babeljs - Babel 没有处理 Array.from 或 'for ... of' 循环

webpack - 获取 @babel/present-env 的默认实现以与 IE11 一起使用

javascript - grunt-browserify 路径必须是字符串错误

gruntjs - 如何在 grunt-watch 任务中忽略一个文件?

ios - React native 全新安装 ReferenceError : Unknown plugin "transform-runtime" specified

node.js - Babel Transpiler 无法与 Nodemon 一起运行

babeljs - babel CLI 复制 nonjs 文件

javascript - Grunt.js 模板 : Use the name of the target in a task?

javascript - 咕噜 watch 。这个配置如何捕获第二级js文件的变化

javascript - 如何在grunt-contrib-copy的进程选项中访问 "pkg.version"?