Skip to content

Instantly share code, notes, and snippets.

@zgordon
Last active July 22, 2021 08:34
Show Gist options
  • Save zgordon/e996a97384a09254f375bc0289b290c7 to your computer and use it in GitHub Desktop.
Save zgordon/e996a97384a09254f375bc0289b290c7 to your computer and use it in GitHub Desktop.
An example .babelrc file for working with Gutenberg
{
"presets": [ "@wordpress/default" ],
"plugins": [
"transform-object-rest-spread",
[
"transform-react-jsx",
{
"pragma": "wp.element.createElement"
}
],
"transform-runtime",
],
}
@cobianzo
Copy link

cobianzo commented Dec 9, 2020

I used it and didnt work. Had to change
"transform-runtime"
for
"@babel/transform-runtime"

and, of course I had to install
npm i @wordpress/babel-preset-default -D
npm install --save-dev babel-plugin-transform-object-rest-spread
npm install --save-dev @babel/plugin-transform-runtime

@crs1138
Copy link

crs1138 commented Jul 22, 2021

Is this the actual version now? Just simple:

{
    "presets": ["@wordpress/babel-preset-default"]
}

and all the rest happens behind the scenes? Or do you need other Babel plugins too?

See more details at https://developer.wordpress.org/block-editor/reference-guides/packages/packages-babel-preset-default/ and https://github.com/WordPress/gutenberg/blob/HEAD/packages/babel-preset-default/index.js

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