pugjs / babel-plugin-transform-react-pug

A plugin for transpiling pug templates to jsx
MIT License
808 stars 46 forks source link

How to use this babel plugin in latest create-react-app ? #87

Open popcornkiller1088 opened 5 years ago

popcornkiller1088 commented 5 years ago

Try to use this plugin in create react app, I run npm eject but that's no .babelrc file, just a config folder with some webpack config.

popcornkiller1088 commented 5 years ago

Hi, just found out put instead of put those code inside babel.rc, I can put those code in package.json.

  "babel": {
    "presets": [
      "react-app"
    ],
    "plugins": [
      "transform-react-pug"
    ]
  },

and will require to install eslint, then, add those code in package.json to configure eslint.

  "eslintConfig": {
    "plugins": [
      "react-pug"
    ],
    "extends": [
      "react-app",
      "plugin:react-pug/all"
    ]
  },
ezhlobo commented 5 years ago

@popcornkiller1088 that's a good information for others, I think we should add this to README. Thanks ;).

Venryx commented 4 years ago

Hi, just found out put instead of put those code inside babel.rc, I can put those code in package.json.

Where did you read this?

I tried, and any babel configuration in the package.json file gets ignored.

popcornkiller1088 commented 4 years ago

My answer is 1 years ago, I think the create-react-app might have change their way of configure things

Venryx commented 4 years ago

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

And this (using it's addBabelPlugin function): https://github.com/arackaf/customize-cra

It works fine (so issue can be closed); though I do wish create-react-app supported configuration extensions intrinsically.