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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add a babel plugin #2611

Closed
bernatfortet opened this issue Jun 25, 2017 · 12 comments
Closed

How to add a babel plugin #2611

bernatfortet opened this issue Jun 25, 2017 · 12 comments

Comments

@bernatfortet
Copy link

bernatfortet commented Jun 25, 2017

Sorry for my ignorance, but after ejecting I can't seem to figure out how to add a plugin,

I'm used to the simplicity of .babelrc but it seems to not work with create-react-app

Thanks.

When I add .babelrc I get the following error:

image

@bernatfortet bernatfortet changed the title How to adda plugin How to add a plugin Jun 25, 2017
@bernatfortet bernatfortet changed the title How to add a plugin How to add a babel plugin Jun 25, 2017
@bernatfortet
Copy link
Author

I looked at this issue: #1069 by gaearon where he basically says:
after ejecting, in order to use .babelrc you need to add "presets": ["react-app"] for it to work

@Altiano
Copy link

Altiano commented Jul 4, 2017

How about without ejecting?

@gaearon
Copy link
Contributor

gaearon commented Jul 4, 2017

There is no way to add a Babel plugin without ejecting. This helps us ensure that the setup works correctly and isn't suspecticle to very common configuration mistakes or inclusion of unmaitained plugins. What plugin did you want to add?

@Altiano
Copy link

Altiano commented Jul 5, 2017

Hmm, so there's no other option unless ejecting.
I want to add babel-plugin-transform-export-extensions.
It is a stage 1 proposal but I think it's a pretty solid one and it has been transfered recently to the official tc39 repo (https://github.com/tc39/proposal-export-default-from)

@gaearon
Copy link
Contributor

gaearon commented Jul 5, 2017

If you consider syntactic sugar to be more important than being able to get updates to underlying tools, then sure, your best option would be to eject. I probably wouldn’t do it on my project even if I liked the syntax.

I’m not aware of any news about this proposal going forward. Moving the repo could just be a logistical decision (worth checking if other proposals did the same).

@vinhlh
Copy link

vinhlh commented Jul 26, 2017

Just want to add my own translation Babel plugin, but ejecting all stuff doesn't look good.

@gaearon
Copy link
Contributor

gaearon commented Jul 26, 2017

I agree we need a better story around handling i18n. A dedicated issue would be better for this though.

@SpencerCDixon
Copy link

+1 to the internationalization issue. I really want to eject just to get https://github.com/akameco/babel-plugin-react-intl-auto and https://github.com/akameco/extract-react-intl-messages working :/

@stoyandamov
Copy link

@SpencerCDixon
Copy link

@stoyandamov I ended up using this: https://github.com/timarney/react-app-rewired

@masumsoft
Copy link

masumsoft commented Mar 21, 2018

We wanted to use the babel plugin provided by styled-components which adds support for server-side rendering, minification of styles and gives a nicer debugging experience while using styled-components with react.

It would be great if we could add plugins by extending the babel config that CRA is currently using internally without ejecting. I guess the api could allow adding something like this in .babelrc or package.json:

{
    "presets": ["react-app"],
    "plugins": ["babel-plugin-styled-components"]
}

@Timer
Copy link
Contributor

Timer commented Mar 25, 2018

You can accomplish this with Babel Macros support coming out in react-scripts@2. See the announcement thread.

@facebook facebook locked and limited conversation to collaborators Mar 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants