3

My folder structure:

package.json
src
├── backend
│   ├── routes
│   │   ├── myRoute.js
├── index.js
├── .babelrc

The command i run from package.json: "build:server": "babel src/backend/ -d dist"

The resulting dist folder structure:

dist
├── src
│   ├── backend
    │   ├── index.js

How can i get it to transpile all subfolders within backend as well? I tried babel src/backend/** -d dist and that didn't work either.

Infamous911
  • 1,441
  • 2
  • 26
  • 41
  • Looks like `index.js` contains everything. Do you wanna check the source? – Praveen Kumar Purushothaman Mar 24 '19 at 21:33
  • 1
    What do you mean it contains everything? I am importing `myRoute.js` in `index.js`. After babel transpiles it and i try to run the `index.js` in `dist` with `node`, I get an error saying `./routes/myRoute.js` cannot be found. – Infamous911 Mar 24 '19 at 21:37
  • What if you move `.babelrc` out of `src` and into the root-level? Then change your command to `babel src -d dist` – Ben Lorantfy Mar 25 '19 at 00:34
  • @BenLorantfy The problem with that is that i already have a root-level `.babelrc` which handles the frontend transpilation – Infamous911 Mar 25 '19 at 01:36

1 Answers1

1

You should move your .babelrc file to the root of your directory

Lin Du
  • 88,126
  • 95
  • 281
  • 483