Skip to content

Instantly share code, notes, and snippets.

@iamdustan
Created April 4, 2017 22:02
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 iamdustan/2908fab8d14f4e3d26feb4c99412801b to your computer and use it in GitHub Desktop.
Save iamdustan/2908fab8d14f4e3d26feb4c99412801b to your computer and use it in GitHub Desktop.
rollup with react-reason starter repo
var rollup = require('rollup').rollup;
var commonjs = require('rollup-plugin-commonjs');
var nodeResolve = require('rollup-plugin-node-resolve');
var replace = require('rollup-plugin-replace');
const entry = 'simple/simpleRoot';
const results = [];
const dest = 'bundle.js';
const ENV = 'development';
// const ENV = 'production';
rollup({
entry: 'lib/es6/src/' + entry + '.js',
dest: dest,
format: 'iife',
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify(ENV),
}),
nodeResolve({
jsnext: true,
main: true,
module: true,
}),
commonjs({
// non-CommonJS modules will be ignored, but you can also
// specifically include/exclude files
include: 'node_modules/**', // Default: undefined
// exclude: [ 'node_modules/foo/**', 'node_modules/bar/**' ], // Default: undefined
// if true then uses of `global` won't be dealt with by this plugin
ignoreGlobal: false, // Default: false
// if false then skip sourceMap generation for CommonJS modules
sourceMap: false, // Default: true
// explicitly specify unresolvable named exports
// (see below for more details)
namedExports: {
'react': [
'createClass',
'createElement',
],
'react-dom': [
'render'
]
}, // Default: undefined
// sometimes you have to leave require statements
// unconverted. Pass an array containing the IDs
// or a `id => boolean` function. Only use this
// option if you know what you're doing!
// ignore: [ 'conditional-runtime-dependency' ]
}),
]
})
.then((all) => {
return all.write({
dest: dest,
format: 'iife'
});
})
.catch(console.log);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment