title: How to use a library from a CDN in a Webpack project in production
body: <p>I'd like to use <code>react.min.js</code> from a CDN in production (e.g. <a href="https://unpkg.com/react@15.3.1/dist/react.min.js" rel="noreferrer">https://unpkg.com/react@15.3.1/dist/react.min.js</a>)</p>
  
  <p>What is the best way to get Webpack to transform my <code>import React from 'react'</code> statements into <code>const React = window.React</code> instead of building <code>node_modules/react</code> into the bundle?                 </p>
  
  <p>I've been doing it with <code>resolve.alias</code> like this:</p>
  
  <p>In <code>index.html</code>:</p>
  
  <pre><code>&lt;head&gt;
    &lt;script type="text/javascript" src="https://unpkg.com/react@15.3.1/dist/react.min.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" src="/assets/bundle.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  </code></pre>
  
  <p>In <code>webpack.prod.config.js</code>:</p>
  
  <pre><code>alias: {
    react$: './getWindowReact',
  },
  </code></pre>
  
  <p><code>getWindowReact.js</code>:</p>
  
  <pre><code>module.exports = window.React;
  </code></pre>
  
  <p><strong>Note</strong>: In the old question I didn't realize that building React into a Webpack bundle with <code>NODE_ENV=production</code> would strip out the <code>propTypes</code> checks.  One of the answers focuses on that.</p>