Last active
January 20, 2016 08:25
-
-
Save vagusX/2821b58eced446e62d31 to your computer and use it in GitHub Desktop.
rollup bundle react
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
<!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> |
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 * 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')) |
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 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