title: Uploading assets to S3 using webpack
body: <p>Currently all images in my react project are being served by the nginx server. These images are bundles with source. The source does not use require/import but instead uses url paths to render the images.</p>
  
  <p>Now I want to serve these images from cloudfront, using S3 as my storage.
  I plan to create a set of assets on S3 for every environment. </p>
  
  <p>I can think of two approaches for doing this:  </p>
  
  <p><strong>Approach 1. Using a script</strong> </p>
  
  <ul>
  <li>create a script that runs after webpack bundling</li>
  <li>the script will upload files to S3 </li>
  <li>paths in script and source will be deduced based on env variables</li>
  </ul>
  
  <p><strong>Approach 2. Create a webpack loader</strong> </p>
  
  <ul>
  <li>update source to import/require images</li>
  <li>create a loader that upload images to S3 and returns public path</li>
  </ul>
  
  <p>Any opinions on these approaches or suggestions on a better approach ?</p>