Created
February 29, 2016 16:03
-
-
Save DexterHaslem/86257bcb44961aba6652 to your computer and use it in GitHub Desktop.
gulp MODERN (feb 2016), WORKING babel + react + sourcemaps. millions of outdated bad examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ "presets": ["react"], "sourceMaps": true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var connect = require('gulp-connect'); | |
var open = require('gulp-open'); | |
var concat = require('gulp-concat'); | |
var lint = require('gulp-eslint'); | |
var babel = require('gulp-babel'); | |
var browserify = require('browserify'); | |
var source = require('vinyl-source-stream'); | |
var babel = require('babelify'); | |
var buffer = require('vinyl-buffer'); | |
var sourcemaps = require('gulp-sourcemaps'); | |
gulp.task('js', function() { | |
browserify('./src/main.js', {debug: true}) | |
.transform(babel) | |
.bundle() | |
.on('error', console.error.bind(console)) | |
.pipe(source('bundle.js')) | |
.pipe(buffer()) | |
// dont forget loadMaps or else it wont work in chrome | |
.pipe(sourcemaps.init({loadMaps: true})) | |
.pipe(sourcemaps.write('./')) | |
.pipe(gulp.dest(config.paths.dist + '/scripts')) | |
.pipe(connect.reload()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment