Skip to content

Instantly share code, notes, and snippets.

@benjaminreid
Created August 10, 2015 15:37
Show Gist options
  • Save benjaminreid/77472c23cf7333a7d387 to your computer and use it in GitHub Desktop.
Save benjaminreid/77472c23cf7333a7d387 to your computer and use it in GitHub Desktop.
ES6
// javascripts/components/foo.js
export default function() {
console.log('foo');
}
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));
});
// javascripts/main.js
import foo from './components/foo';
// logs foo
foo();
@benjaminreid
Copy link
Author

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/

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