Skip to content

Instantly share code, notes, and snippets.

@vagusX
Last active January 20, 2016 08:25
Show Gist options
  • Save vagusX/2821b58eced446e62d31 to your computer and use it in GitHub Desktop.
Save vagusX/2821b58eced446e62d31 to your computer and use it in GitHub Desktop.
rollup bundle react
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rock Roll</title>
</head>
<body>
<div id='root'></div>
<script src='./build/bundle.js'></script>
</body>
</html>
import * as React from 'react'
import * as ReactDOM from 'react-dom'
const App = React.createClass({
componentDidMount() {
console.log('123')
},
render() {
return (
<div>Rock Roll</div>
)
}
})
ReactDOM.render(<App />, document.querySelector('#root'))
import babel from 'rollup-plugin-babel'
import uglify from 'rollup-plugin-uglify'
import npm from 'rollup-plugin-npm'
import commonjs from 'rollup-plugin-commonjs'
import replace from 'rollup-plugin-replace'
export default {
entry: 'src/main.js',
dest: 'build/bundle.js',
format: 'iife',
plugins: [
replace({
'process.env.NODE_ENV': '"production"'
}),
babel({
babelrc: false,
exclude: 'node_modules/',
presets: ['es2015-rollup', 'stage-0', 'react']
}),
npm({
jsnext: true,
main: true,
}),
commonjs({
include: 'node_modules/'
})
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment