Code Monkey home page Code Monkey logo

gulp-babel's Introduction

gulp-babel Build Status

Turn ES6 code into vanilla ES5 with no runtime required using babel

Issues with the output should be reported on the babel issue tracker.

Install

$ npm install --save-dev gulp-babel

Usage

var gulp = require('gulp');
var babel = require('gulp-babel');

gulp.task('default', function () {
	return gulp.src('src/app.js')
		.pipe(babel())
		.pipe(gulp.dest('dist'));
});

API

babel([options])

options

See the babel options, except for sourceMap and filename which is handled for you.

Source Maps

Use gulp-sourcemaps like this:

var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var babel = require('gulp-babel');
var concat = require('gulp-concat');

gulp.task('default', function () {
	return gulp.src('src/**/*.js')
		.pipe(sourcemaps.init())
		.pipe(babel())
		.pipe(concat('all.js'))
		.pipe(sourcemaps.write('.'))
		.pipe(gulp.dest('dist'));
});

Babel Metadata

Files in the stream are annotated with a babel property, which contains the metadata from babel.transform().

Example

var gulp = require('gulp');
var babel = require('gulp-babel');
var through = require('through2');

function logFileHelpers() {
	return through.obj(function (file, enc, cb) {
		console.log(file.babel.usedHelpers);
		cb(null, file);
	});
}

gulp.task('default', function () {
	return gulp.src('src/**/*.js')
		.pipe(babel())
		.pipe(logFileHelpers);
})

License

MIT © Sindre Sorhus

gulp-babel's People

Contributors

sindresorhus avatar sebmck avatar darvelo avatar ultcombo avatar you-think-you-are-special avatar nstepien avatar hemanth avatar

Watchers

James Cloos 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.