title: How to build different versions with environment variables
body: <p>According to <a href="https://github.com/electron-userland/electron-builder/issues/1966" rel="nofollow noreferrer">this</a> it is not possible to set flags within an electron app with environment variables. I still need to build different versions of the app for dev, staging, pilot and prod.</p>
  
  <p>Internally I would like to use <a href="https://github.com/dw1284/electron-node-config" rel="nofollow noreferrer"><code>electron-node-config</code></a> because it's just easy. But because I have no access to environment variables it's not possible to use <code>node-config</code>.</p>
  
  <p>So I thought of having several entry scripts like</p>
  
  <pre><code>// index.dev.js
  require('./main')({ APP_URL: 'localhost:8080' });
  
  // index.staging.js
  require('./main')({ APP_URL: 'https://staging.foo.com' });
  
  // pilot.staging.js
  require('./main')({ APP_URL: 'https://pilot.foo.com' });
  </code></pre>
  
  <p>Where my <code>main.js</code> file looks <em>more or less</em> like this</p>
  
  <pre><code>module.exports = (config) =&gt; {
    app.on('ready', () =&gt; {
      mainWindow.loadURL(config.APP_URL);
    });
  };
  </code></pre>
  
  <p>However, in the electron builder docs there doesn't seem to be an option for specifying an entry file, it always uses <code>index.js</code> to package the app, and there isn't much written in the docs for the js api other than</p>
  
  <pre><code>const builder = require('electron-builder');
  const env = process.env.NODE_ENV;
  const entry = `index.${env}.js`;
  
  builder.build({
    entry,
    appId: 'com.electron.foo',
    productName: 'foo',
    mac: {
      target: 'zip'
    },
    win: {
      target: 'portable'
    },
    portable: {
      artifactName: 'foo.exe'
    }
  });
  </code></pre>
  
  <p>So I tried setting up my package.json like this</p>
  
  <pre><code>"scripts": {
    "build:staging": "NODE_ENV=development node scripts/build",
    "build:pilot": "NODE_ENV=pilot node scripts/build",
    "build:production": "NODE_ENV=production node scripts/build"
  }
  </code></pre>
  
  <p>However I'm really not sure how to set the entry file for electron builder config. How do I specify an entry file?</p>