-
I have a somewhat unique problem. I want to transpile a bunch of files through babel. My problem is: Depending on the first comment header I need different targets (e.g. some files might be targeting the browser and some targeting node). Is there any way to write a plugin that gets invoked first. For example, do a simple string contains check to see what type of file it is and then modify the targets or do I have to try to cover everything based on include and exclude patterns and based on filenames? Or is there maybe even a third option? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
A plugin could manipulate Babel options by
Yes. And you can read all sources, check certain strings, and programmatically generate |
Beta Was this translation helpful? Give feedback.
A plugin could manipulate Babel options by
manipulateOptions()
, but it could do so only at the config resolving phase. At the time when Babel is processing the input source, the config can no longer be mutated.Yes. And you can read all sources, check certain strings, and programmatically generate
input
andexclude
forbabel.config.js
.