Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build non js file using babel?

In a nodejs express.js application, and trying to build the app using babel for cross browser compatibility.

package.json scripts:

"scripts": {
       "start": "node dist/app.js",
       "build": "babel src -d dist"
}

On running npm build and check my build folder everything builds correctly except my non-js files like [.html,.css,.ejs]. At the moment just copied those file to the build folder in their respective sub directories and everything works fine.

I have even tried "build": "babel src -d dist --ignore *.css,*.ejs,*.png,*.jpg"

Is there a way to do this in a better way instead of copying the non-js files. Thanks in advance any help will be highly appreciated.

like image 969
Zadiki Hassan Ochola Avatar asked Sep 16 '18 16:09

Zadiki Hassan Ochola


1 Answers

If you have non-JavaScript files in the source directory that should be automatically copied to the output location when the command is run, simply add the --copy-files flag.

babel src -d dist --copy-files

The flag doesn't take any arguments and will copy all non-JS files over.

like image 198
Adam Avatar answered Oct 15 '22 09:10

Adam