Skip to content

Instantly share code, notes, and snippets.

@cmawhorter
Created January 20, 2017 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmawhorter/5a7abb0fd269f7051de8097c4f079213 to your computer and use it in GitHub Desktop.
Save cmawhorter/5a7abb0fd269f7051de8097c4f079213 to your computer and use it in GitHub Desktop.
rollup and babel cwd
'use strict';
const path = require('path');
const rollup = require('rollup');
const babel = require('rollup-plugin-babel');
const nodeResolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs');
const builtins = require('rollup-plugin-node-builtins');
const globals = require('rollup-plugin-node-globals');
var cache;
console.log('Build started...');
let defaultRollupOptions = {
entry: path.join(process.cwd(), 'src/main.js'),
cache: cache,
plugins: [
globals(),
builtins(),
nodeResolve({
jsnext: true,
main: true,
}),
commonjs({
include: 'node_modules/**'
}),
babel({
exclude: 'node_modules/**',
presets: [ [ 'es2015', { modules: false } ] ],
plugins: [ 'external-helpers' ],
babelrc: false,
}),
],
external: [
'aws-sdk',
],
};
rollup.rollup(defaultRollupOptions).then(bundle => {
cache = bundle; // build doesn't watch so this isn't used
bundle.write({
format: 'cjs',
sourceMap: true,
dest: 'dist/index.js',
});
console.log('Build complete.');
});
{
"dependencies": {
"rollup": "^0.41.4",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-commonjs": "^7.0.0",
"rollup-plugin-node-builtins": "^2.0.0",
"rollup-plugin-node-globals": "^1.1.0",
"rollup-plugin-node-resolve": "^2.0.0"
}
}
export default function() {
console.log('hello');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment