Skip to content

Instantly share code, notes, and snippets.

@jimmythompson
Last active February 21, 2016 00:20
Show Gist options
  • Select an option

  • Save jimmythompson/6331b9fe29a63e06d12a to your computer and use it in GitHub Desktop.

Select an option

Save jimmythompson/6331b9fe29a63e06d12a to your computer and use it in GitHub Desktop.
Gulp babel example
var gulp = require("gulp"),
gulpWebpack = require("gulp-webpack"),
webpack = require("webpack");
var buildDirectory = "build";
gulp.task("build-source", function () {
return gulp
.src("src/js/main.jsx")
.pipe(gulpWebpack({
output: {
filename: "bundle.js"
},
resolve: {
extensions: [ '', '.js', '.jsx' ]
},
module: {
loaders: [{
test: /\.jsx?$/,
loader: 'babel',
exclude: /node_modules/,
query: {
presets: ['react', 'es2015']
}
}]
},
plugins: [
new webpack.ProvidePlugin([
'react'
])
]
}))
.pipe(gulp.dest(buildDirectory));
});
@jimmythompson
Copy link
Author

To get this working you'll also need to install the following npm packages:

  • gulp
  • webpack
  • gulp-webpack
  • babel-core
  • babel-loader
  • babel-preset-es2015
  • babel-preset-react

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