gocreating
gocreating

Reputation: 171

How to customize babel 6 plugin/preset root

I have one cli project and one boilerplate project. Now I want to install all babel plugins and presets inside the cli, and use the cli to transpile the boilerplate.

The problem is, I'd like to run cli commands in boilerplate directory, and babel always looks for plugins/presets from boilerplate/node_modules instead of cli/node_modules.

How can I config babel to search only cli/node_modules? I've tried to set sourceRoot and moduleRoot, but neither work.

Upvotes: 1

Views: 344

Answers (1)

loganfsmyth
loganfsmyth

Reputation: 161517

You can explicitly pass the resolved plugins, e.g.

transform(code, {
    preset: [require('babel-preset-es2015')],
});

Upvotes: 2

Related Questions