babel CLI copy nonjs files

I found a way to do this by using the ncp module

npm install ncp

This module is basically like a cp except it works on

This isn't a global module, so to run this we use

node -e \"require('ncp').ncp('./src', './lib')\" && babel src --out-dir lib

Babel has the copy files option for this:

babel src --out-dir lib --copy-files

Note: It is true that babels primary purpose is to process javascript files, but babel's big suite of tools these day often makes it unnecessary to go for more complex build script setups as gulp and alike. A gulp-less setup could be adding this to packages.json:

{
  ...
  "devDependencies": {
    "babel": "*",
    "babel-cli": "^6.4.0",
    "babel-preset-es2015": "^6.3.13"
  },
  "scripts": {
    "watch": "babel --watch src --out-dir lib --source-maps inline --copy-files",
    "build": "babel src --out-dir lib --source-maps inline --copy-files" 
  },
  "babel": {
    "presets": [
      "es2015"
    ]
  }
}

Tags:

Babeljs