Using Webpack with React
Webpack is a module bundler similar to Browserify but with a different philosophy. Browserify was born with the goal of making it possible for developers to write CommonJS(node code) in the browser. Webpack allows you to write CommonJS but it also allows you to use other formats that might not be supported by node. One thing that makes it interesting is that since it doesn’t try to comply with CommonJS, it allows developers to declare dependencies on files that are not necessarily JS, which can be helpful to create self contained components.
Getting started with Webpack
Lets create a simple React app using Webpack. We can start by creating our HTML entry point:
1
2
3
mkdir ~/webpack
cd ~/webpack
touch index.html