title: module.exports function is not a function
body: <p>I'm trying to require an endpoints.js file into my webpack.config.js</p>
  <h3>Expected</h3>
  <p>endpoints.js gets required correctly then sets a custom api file depending on the <code>process.env.NODE_ENV</code></p>
  <h3>Results</h3>
  <p><a href="https://i.stack.imgur.com/jHytZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jHytZ.png" alt="enter image description here" /></a></p>
  <p><code>const api = endpoints(process.env.NODE_ENV);</code></p>
  <blockquote>
  <p>TypeError: endpoints is not a function</p>
  </blockquote>
  <hr />
  <h1>Webpack.config.js</h1>
  <pre><code>const webpack = require('webpack')
  const HtmlWebpackPlugin = require(&quot;html-webpack-plugin&quot;);
  const ExtractTextPlugin = require(&quot;extract-text-webpack-plugin&quot;);
  const CopyWebpackPlugin = require(&quot;copy-webpack-plugin&quot;);
  const path = require(&quot;path&quot;);
  const dist = path.resolve(__dirname, &quot;dist&quot;);
  const src = path.resolve(__dirname, &quot;src&quot;);
  const endpoints = require(&quot;./src/endpoints&quot;);
  const api = endpoints(process.env.NODE_ENV);
  
  console.log('webpack endpoints', endpoints);
  console.log('webpack api', api);
  </code></pre>
  <hr />
  <h1>endpoints.js</h1>
  <pre><code>module.exports = {
      endpoints: function(env) {
          let prefix = env === 'development' ? 'http://localhost' : '';
  
          return {
              &quot;login&quot;: `${prefix}/app/api/login`
          }
      }
  }
  </code></pre>
  <p>I also tried the following, but got an <strong>Unexpected token export</strong></p>
  <pre><code>export default function endpoints(env) {
      let prefix = env === 'development' ? 'http://localhost' : '';
  
      return {
          &quot;login&quot;: `${prefix}/app/api/login`
      }
  };
  </code></pre>