Search code examples
webpackproduction-environment

How can I start production with webpack?


So far I've been developing with express, react, webpack and socket io on development side, but I wanna start to work on the production site. What modules shold I get? I also would appreciate any set up source for production, ty!


Solution

  • It's hard to suggest what changes you need to make to prepare your app for production without knowing exactly what you're currently doing in development however a few things to consider include:

    • Serve static files -- If you're using webpack-dev-server or webpack-dev-middleware during development you'll want to make sure you instead bundle and serve static files for production using the regular webpack cli.
    • Minify bundle -- This can be done by passing -p to the webpack cli or by adding the UglifyJsPlugin to your config.
    • Revision assets -- This will allow you to take advantage of long term browser caching.

    You might like to take a look at the 60fram.es boilerplate which includes both development and production builds.