【问题标题】:keep dot separated file grunt-babel保持点分隔文件 grunt-babel
【发布时间】:2015-07-28 02:44:19
【问题描述】:

我正在使用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'
    }]
  }
}

【问题讨论】:

  • 如果您分享相关代码会有所帮助
  • @sfletche 更新了问题。请检查您是否可以提供帮助!

标签: gruntjs babeljs


【解决方案1】:

您可以完全删除 ext 属性,也可以添加值为 last 的 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 用于表示表示分机的句号所在的位置。可以取“first”(扩展名从文件名中的第一个句点之后开始)或“last”(扩展名从最后一个句点开始),默认设置为“first”[0.4.3 中添加]

【讨论】:

    猜你喜欢
    • 2015-12-10
    • 2016-03-05
    • 2018-07-07
    • 2015-12-03
    • 2014-12-18
    • 2018-11-25
    • 2013-03-22
    • 2010-11-11
    • 1970-01-01
    相关资源
    最近更新 更多