Created
January 20, 2017 02:19
-
-
Save cmawhorter/5a7abb0fd269f7051de8097c4f079213 to your computer and use it in GitHub Desktop.
rollup and babel cwd
This file contains hidden or 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
'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.'); | |
}); |
This file contains hidden or 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
{ | |
"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" | |
} | |
} |
This file contains hidden or 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
export default function() { | |
console.log('hello'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment