Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

babel CLI copy nonjs files

Tags:

babeljs

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?

like image 261
yangli-io Avatar asked Sep 18 '15 01:09

yangli-io


2 Answers

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"     ]   } } 
like image 62
Emil Ingerslev Avatar answered Oct 16 '22 08:10

Emil Ingerslev


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 
like image 40
yangli-io Avatar answered Oct 16 '22 07:10

yangli-io