Coder Social home page Coder Social logo

babel-brunch's Introduction

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 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

babel-brunch's People

Contributors

alexgb avatar anaphase avatar colinbate avatar es128 avatar goshacmd avatar jblock avatar lydell avatar marcioj avatar paulmillr avatar razor-x avatar realistschuckle avatar rstacruz avatar sebmck avatar shvaikalesh avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.