title: Accessing global variable after webpack build
body: <p>Let I have a file index.js with content</p>
  
  <pre><code>var a = 1;
  </code></pre>
  
  <p>I have index.html file which include index.js using <code>&lt;script&gt;</code> tag.
  When I open index.html page in browser, then the <code>a</code> variable can be accessed directly in browser console. Because <code>a</code> have global scope and it is global variable.</p>
  
  <p>Now I am using npm and webpack. 
  My package.json file content is</p>
  
  <pre><code>"scripts": {
    "build": "webpack"
  },
  </code></pre>
  
  <p>and webpack.config.js file content is</p>
  
  <pre><code>module.exports = {
  entry: './index.js',
  output: {
      path: path.resolve(__dirname, 'dist'),
      filename: 'bundle.js'
    },
  }
  </code></pre>
  
  <p>Now I run npm build then new file is created in dist folder named bundle.js.</p>
  
  <p>Now I replace index.js from <code>script</code> tag of index.html file with dist/bundle.js .</p>
  
  <p>Now I run index.html in browser, but variable <code>a</code> is no longer access in browser console directly. It is not a global variable now.</p>
  
  <p>My question is : 
  Is there a way by which we can access variable <code>a</code> globally just like we access initially?</p>
  
  <p>I have not found exact answer on internet. I found a loader <a href="https://webpack.js.org/loaders/expose-loader/" rel="noreferrer">expose-loader</a> but it also can't solve my problem.</p>