Last active
November 1, 2016 16:15
-
-
Save magicspon/db9b427b778b54b122502a950970e057 to your computer and use it in GitHub Desktop.
rollup.js
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
import gulp from 'gulp' | |
import rollup from 'rollup-stream' | |
import babel from 'rollup-plugin-babel' | |
import eslint from 'rollup-plugin-eslint' | |
import resolve from 'rollup-plugin-node-resolve' | |
import commonjs from 'rollup-plugin-commonjs' | |
import replace from 'rollup-plugin-replace' | |
import uglify from 'rollup-plugin-uglify' | |
import config from '../config' | |
import source from 'vinyl-source-stream' | |
import handleErrors from '../util/handleErrors' | |
const $js = config.js | |
const options = { | |
entry: $js.src, | |
dest: `${$js.dest}/${$js.output}`, | |
format: 'iife', | |
sourceMap: (process.env.NODE_ENV !== 'production' && 'inline'), | |
plugins: [ | |
resolve({ | |
jsnext: true, | |
main: true, | |
browser: true, | |
}), | |
commonjs({ | |
namedExports: { | |
'node_modules/jquery/dist/jquery.min.js': [ '$' ], | |
} | |
}), | |
// eslint({ | |
// exclude: [ | |
// // styles? | |
// ] | |
// }), | |
babel({ | |
exclude: 'node_modules/**', | |
include: 'node_modules/lory.js/src/**/*.js', | |
presets: ['es2015-rollup', 'stage-0'], | |
plugins: [ | |
"syntax-object-rest-spread", | |
"transform-es2015-parameters", | |
"transform-es2015-destructuring", | |
"transform-object-rest-spread" | |
], | |
babelrc: false | |
}), | |
replace({ | |
ENV: JSON.stringify(process.env.NODE_ENV || 'development') | |
}), | |
(process.env.NODE_ENV === 'production' && uglify()) | |
] | |
} | |
gulp.task('rollup', function() { | |
return rollup(options) | |
// give the file the name you want to output with | |
.pipe(source($js.output)) | |
.on('error', handleErrors) | |
// and output to ./dist/app.js as normal. | |
.pipe(gulp.dest($js.dest)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment