Created
August 10, 2015 15:37
-
-
Save benjaminreid/77472c23cf7333a7d387 to your computer and use it in GitHub Desktop.
ES6
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
// javascripts/components/foo.js | |
export default function() { | |
console.log('foo'); | |
} |
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 babelify = require('babelify'); | |
var browserify = require('browserify'); | |
var source = require('vinyl-source-stream'); | |
var paths = { | |
js: { | |
file: 'main.js', | |
src: './javascripts/main.js', | |
watch: './javascripts/**/*.js', | |
dist: './assets', | |
output: './assets/main.js', | |
} | |
}; | |
gulp.task('js', function() { | |
return browserify({ entries: paths.js.src, debug: true }) | |
.transform(babelify) | |
.bundle() | |
.pipe(source(paths.js.file)) | |
.pipe(gulp.dest(paths.js.dist)); | |
}); |
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
// javascripts/main.js | |
import foo from './components/foo'; | |
// logs foo | |
foo(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've commented their file locations as Github wouldn't let me specify them in the file name.
I stole this from: http://advantcomp.com/blog/ES6Modules/