Skip to content

Instantly share code, notes, and snippets.

@saddieeiddas
Created December 3, 2015 22:38
Show Gist options
  • Select an option

  • Save saddieeiddas/07ec5b03bdacde473e39 to your computer and use it in GitHub Desktop.

Select an option

Save saddieeiddas/07ec5b03bdacde473e39 to your computer and use it in GitHub Desktop.
Rollup Test
var gulp = require('gulp');
var runSequence = require('run-sequence');
var plugins = require('gulp-load-plugins')({
pattern: [
'gulp-*',
'gulp.*',
'rollup-plugin-npm',
'rollup-plugin-commonjs',
'rollup-plugin-babel'
]
});
gulp.task('default', function(callback) {
runSequence('build', 'watch', callback);
});
gulp.task('watch', function() {
gulp.watch('src/**/*.js', ['js']);
});
gulp.task('build', ['js'])
gulp.task('js', function(callback) {
runSequence('js:rollup', callback);
});
gulp.task('js:rollup', function() {
return gulp.src('src/app.js', {read: false})
.pipe(plugins.plumber())
.pipe(plugins.rollup({
sourceMap: true,
moduleName: 'app',
format: 'iife',
plugins: [
plugins.rollupPluginNpm({
jsnext: true,
main: true
}),
plugins.rollupPluginCommonjs({
include: 'node_modules/**',
exclude: []
}),
plugins.rollupPluginBabel({
sourceMap: true,
compact: false,
comments: false,
presets: ['es2015-rollup']
})
]
}))
.pipe(plugins.sourcemaps.write('.', {sourceRoot: '../'}))
.pipe(gulp.dest('build'));
});
gulp.task('js:uglify', function() {
return gulp.src('test/app.js')
.pipe(plugins.plumber())
.pipe(plugins.sourcemaps.init({loadMaps: true}))
.pipe(plugins.uglify({}))
.pipe(plugins.rename('app.min.js'))
//.pipe(plugins.sourcemaps.write('.')) // enable/disable sourcemaps
.pipe(gulp.dest('build'));
})
{
"private": true,
"name": "rollup-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel-preset-es2015-rollup": "^1.0.0",
"gulp": "^3.9.0",
"gulp-if": "^2.0.0",
"gulp-load-plugins": "^1.1.0",
"gulp-plumber": "^1.0.1",
"gulp-rename": "^1.2.2",
"gulp-rollup": "^1.4.0",
"gulp-sourcemaps": "^1.6.0",
"gulp-uglify": "^1.5.1",
"rollup-plugin-babel": "^2.2.0",
"rollup-plugin-commonjs": "^1.4.0",
"rollup-plugin-npm": "^1.1.0",
"run-sequence": "^1.1.5"
},
"dependencies": {
"jquery": "^1.11.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment