title: Socket.io not globally available when using Webpack
body: <p>Everything was working fine before adding webpack. Here's my current config <em>(below)</em>. Inside login.js, there's a window.onload function, then shortly after there's a socket.on function, which is now breaking the program. It seems as if "socket" is not globally available to the other files after adding webpack.</p>
  
  <p>Here's the error code I receive in console when running my app:<br>
   <em>"login.js:1 Uncaught TypeError: socket.on is not a function at window.onload (login.js:1)"</em></p>
  
  <p>Any help or insight would be appreciated. </p>
  
  <p><strong>webpack.config</strong></p>
  
  <pre><code>const path = require('path')
  
  module.exports = {
      entry: {
          scripts: './src/scripts.js',
          login: './src/login.js'
      },
      output: {
          path: path.resolve(__dirname, 'public/js'),
          filename: '[name].js'
      }, 
      module: {
          rules: [{
              test: /\.js$/,
              exclude: /node_modules/,
              use: {
                  loader: 'babel-loader',
                  options: {
                      presets: ['env']
                  }
              }
          }]
      },
      devServer: {
          contentBase: path.resolve(__dirname, 'public'),
          publicPath: '/js/'
      }
  }
  </code></pre>
  
  <p><strong>Script section of index.html</strong></p>
  
  <pre><code>  &lt;script src="./socket.io/socket.io.js"&gt;&lt;/script&gt;
    &lt;script src="./js/scripts.js"&gt;&lt;/script&gt;
    &lt;script src="./js/login.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  </code></pre>
  
  <hr>
  
  <p>Worked fine before, so I don't believe there's an issue here: </p>
  
  <p><strong>Server</strong></p>
  
  <pre><code>const http = require('http').Server(app);
  const io = require('socket.io')(http);
  </code></pre>
  
  <p><strong>Client</strong><br>
  scripts.js (not in a function, globally declared):</p>
  
  <pre><code>const socket = io();
  let socketid;
  socket.on('connect', () =&gt;  socketid = socket.io.engine.id);
  </code></pre>
  
  <p>login.js (inside window.onload function):</p>
  
  <pre><code>socket.on('check email', () =&gt; {
          setTimeout(() =&gt; refreshPage(), 7500);
          popupbox({
              titletext: 'Verify email', messagetext: 'A verification link has been sent, please verify your email address within 24 hours.', 
              okaytext: 'Okay', okayfunction: () =&gt; refreshPage(),
              customcolor: "#007C5B"
          });
      });
  </code></pre>