We use Webpack 2.0 for any rich user interfaces, which need a lot of compilation, transpiling, etc. It is not commonly used for APIs. It is used in our TELUS Isomorphic Starter Kit to compile the React.js code into a rich isomorphic web application, that can be run in Node.js and in the browser, alike.
Webpack supports two modes of transpilation, based on the
NODE_ENV environment variable.
To start in development mode, run
yarn run dev. This yarn script will set NODE_ENV=development and use Webpack's development configuration. This transpiles your content on the fly, in memory. The application will be slower, but can support features such as hot reloading, etc.
To start in production mode, there are two steps:
yarn run build and
yarn start, both of which use NODE_ENV=production. Your site will be compiled into static assets, under the
/dist folder. The application will run much faster, and cannot be modified during runtime.
The build command should be run in your Dockerfile, so that the static assets are compiled into your production Docker image. This compilation takes a lot of CPU, memory and time, so it is important not to do this compilation on startup.