Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Run babel on specific file #15471

Closed
1 task done
mohit217 opened this issue Mar 5, 2023 · 4 comments
Closed
1 task done

[Feature] Run babel on specific file #15471

mohit217 opened this issue Mar 5, 2023 · 4 comments

Comments

@mohit217
Copy link

mohit217 commented Mar 5, 2023

馃捇

  • Would you like to work on this feature?

What problem are you trying to solve?

I am trying to run Babel on a specific file using babel.config.js but couldn't find out a way to do it. I saw a way to do it https://babeljs.io/docs/options#test using this option but it doesn't use the option and runs on everything.

I found a work around for this here, #5420 (comment) but I want to use just babel instead of webpack.

Describe the solution you'd like

Use test at top level for plugin options.

Describe alternatives you've considered

#5420 (comment)

Documentation, Adoption, Migration Strategy

No response

@babel-bot
Copy link
Collaborator

Hey @mohit217! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

@liuxingbaoyu
Copy link
Member

https://babeljs.io/docs/options#only

Are you looking for it?

@mohit217
Copy link
Author

mohit217 commented Mar 5, 2023

@liuxingbaoyu I want to run a specific plugin only for a specific file. I tried with only as an option for plugin but it didn't work

@JLHwung
Copy link
Contributor

JLHwung commented Mar 9, 2023

I want to run a specific plugin only for a specific file.

Let specific file denoted by foo.js, if you really want to isolate foo.js's config from other sources, you can create a new Babel config file (foo.babel.config.json) just for that foo.js. And then add a new pass to your build commands:

npx babel --config-file foo.babel.config.json --out-dir ./foo-output.js ./foo.js

In your main Babel config, you should ignore ./foo.js:

{
  "ignore": "./foo.js"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants