Features Videos Help About Updates
Menu Buy Now

Babel

First Steps:
Getting Started
Live-Reload Browsers
Browser Sync
Set Language Options
Set Output Paths & Action
Second Steps:
Defaults For New Projects
Build Your Project
Set Target Browsers
Stuff To Know:
CodeKit + Git
Troubleshooting
License Recovery
PostCSS Tools:
Autoprefixer
PurgeCSS
Custom PostCSS Plugins
Other Tools:
npm
Babel — (JS Transpiler)
Terser — (JS Minifier)
Rollup — (JS Bundler)
Cache-Buster
HTML-Minifier
LightningCSS
Bless
Languages:
Sass
Less
Stylus
JavaScript
CoffeeScript
TypeScript
Pug
Haml
Slim
Kit
Markdown
JSON
Image Optimizers:
WebP
PNG
JPEG
SVG
GIF
Frameworks:
CodeKit Frameworks
Tailwind
Bootstrap
Bourbon
Bitters
Zurb Foundation
Susy
Nib
Jeet
Syntax Checkers:
ESLint
Advanced:
Hooks
Environment Variables
Adding Custom Languages
Team Workflows
Scripting CodeKit
Editor Plugins:
Nova
Atom
Sublime Text
Coda 2
More
Read-Only Mode
Upgrading From 2.0
FAQ
The Babel logo

What's Babel?

The latest release of JavaScript, called ES2022, has a lot of features that browsers don't support yet.

You don't have to wait. You can write ES2022 now and Babel will transform it into syntax that today's browsers understand.

Why Do This?

First, because cutting-edge JavaScript is much nicer to use and more powerful. Secondly, because many frameworks like Zurb Foundation and React now rely on Babel. They won't work without it.


Enabling Babel

a screenshot of the babel pop up button in the JavaScript file inspector in CodeKit

Select a JavaScript file and look at the Inspector Pane. Choose "Babel" from the Transpile With pop-up button.

You can also enable Babel for all JS files at once. Open Project Settings and choose the JavaScript category.

Note: If you use Babel, the only syntax checker you should choose is ESLint. It's the only one that understands ES2015 syntax.


Configuring Babel

Open Project Settings and choose the Babel category:

a screenshot of the babel category of project settings in the CodeKit window
Automatic Configuration

By default, Babel will automatically configure itself to support the browsers you specify in Target Browsers.

If needed, you can manually configure Babel by changing the "Babel Configuration" option and then enabling specific Babel plugins from the list.

Basic Options

The before/after comments will wrap Babel-generated code so you can see what the transpiler produces. For details about the remaining options shown above, see the Babel documentation.

Babel Config Files

You can also configure Babel using special files named .babelrc. By default, CodeKit ignores these files. To change that, check the "enable support for .babelrc files" box. Settings from your configuration file will be merged with those from CodeKit's UI

You can also tell CodeKit to use only your .babelrc files. To do that, select the appropriate option in the "Babel Configuration" pop-up button.

React and Flow

If your project uses React or Flow, just check the appropriate box to enable support for each.

The "UseBuiltIns" Option

Sometimes, Babel needs to include helper functions to make newer JavaScript features (like async/await) work in older browsers. These are called "polyfills." The useBuiltIns option controls how Babel adds polyfills:

  • False — Babel won't add polyfills; you must include them yourself.
  • Entry — You must import core-js and regenerator-runtime in your JS file. Babel will find and replace those imports with the exact polyfills your code needs.
  • Usage — Babel will automatically add polyfills as required. You need not import anything in your JS files.

When you select Entry or Usage, CodeKit will verify that your project has core-js and regenerator-runtime installed. If it does not, you'll be prompted to install them. That's required to make the polyfills work.


How Do I Use Async/Await?

You follow three steps:

  1. In Project Settings > Babel, set the useBuiltIns option to "Usage".
  2. If CodeKit offers to install two npm packages, say yes.
  3. Select your JS file in CodeKit, and set the Transpile With option to "Babel".

Custom Babel Presets & Plugins

There are hundreds of third-party Babel plugins. To use them with CodeKit, add their names to the "custom plugins" field:

a screenshot of the custom plugins and presets text fields in the codekit window

You must install these plugins using npm, since they don't ship with CodeKit. They should be in a node_modules directory under your Project's Root Folder. Verify that each one is compatible with the version of Babel in CodeKit (see the About Window). You may want to use a .babelrc file if your third-party plugins require custom options.


Individual Plugins

Finally, you can enable individual Babel plugins, if needed:

a screenshot of the individual plugin options in the codekit window

The plugins are grouped by their official category. Check the box to enable a plugin or leave it unchecked to disable it.

Note:If Babel is set to "auto-configure", any plugins that you select are passed in addition to the plugins that Babel automatically enables to support your target browsers.

Made in San Diego, CA

Follow the Developer on Twitter

Email Support

Report a Bug

Privacy Policy