Brunch plugin for Babel
JavaScript
Latest commit 95298bc Dec 27, 2016 @paulmillr paulmillr committed on GitHub Merge pull request #47 from denysdovhan/patch-1
--save → --save-dev
Permalink
Failed to load latest commit information.
.eslintrc.json Refactor. Feb 24, 2016
.gitignore initial commit Sep 30, 2014
.npmignore initial commit Sep 30, 2014
.travis.yml run Travis on node 6 Jul 1, 2016
LICENSE Copyright year Jan 8, 2015
README.md `--save` -> `--save-dev` Dec 23, 2016
index.js Fix for brunch/brunch#1549. Dec 23, 2016
package.json Release 6.0.6. Aug 17, 2016
test.js Update tests to actuall behavior Dec 23, 2016

README.md

babel-brunch

Brunch plugin using babel to turn latest ECMAScript standard code into vanilla ES5 with no runtime required.

All the .js files in your project will be run through the babel compiler, except those it is configured to ignore, unless you use the pattern option.

Additionally, starting Brunch 2.7.3, babel-brunch will also compile NPM dependencies.

Installation

npm install --save-dev babel-brunch

Usage

  • No configuration is required by default. es2015 and es2016 presets are included.
  • To add React preset:
    • Execute npm install --save-dev babel-preset-react, then adjust the presets option in brunch-config.js:
    • plugins: {babel: {presets: ['es2015', 'es2016', 'react']}}
  • Default behavior is to handle js files which are not dependencies and jsx files if you enable React preset.
  • To specify preset options: {presets: [['transform-es2015-template-literals', { spec: true }]]}

Configuration

Set babel options in your brunch config (such as brunch-config.js) except for filename and sourceMap which are handled internally.

This plugin uses, by default, the es2015 and es2016 presets. To use no preset, set the configuration option to an empty array.

Additionally, you can set an ignore value to specify which .js files in your project should not be compiled by babel. By default, ignore is set to /^(bower_components|vendor)/.

You can also set pattern to a regular expression that will match the file paths you want compiled by babel, which will override the standard behavior of compiling every .js file.

plugins: {
  babel: {
    presets: ['es2015', 'es2016', 'react'], // es2015, es2016 are defaults
    ignore: [
      /^(bower_components|vendor)/,
      'app/legacyES5Code/**/*'
    ],
    pattern: /\.(es6|jsx)$/ // js and jsx are defaults.
  }
}

Change Log

See release notes page on GitHub

License

ISC