babel CLI copy nonjs files
I'm running a babel cli command
babel src --out-dir lib
To copy the es6 scripts from src into lib. However, it wont copy css/scss files I have in the src/ folder. Is there a way to make it copy them as well?
Solution 1:
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"
]
}
}
Solution 2:
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