<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the <a href="https://github.com/zeit/next.js/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h2 dir="auto">Expected Behavior</h2>
<p dir="auto">Client side routing, navigation and routing would work.</p>
<h2 dir="auto">Current Behavior</h2>
<p dir="auto">Ran <code class="notranslate">next export</code> and when I serve locally (and online) there's a client side JavaScript error that breaks all the client side logic.</p>
<p dir="auto">Without sourcemaps (or any other debugging tools?) I can't work out what's happening. Live URL: <a href="https://dkfyjniin9u60.cloudfront.net/" rel="nofollow">https://dkfyjniin9u60.cloudfront.net/</a> (see console in browser).</p>
<p dir="auto">Not sure I can replicate as yet, as it's larger site - pretty sure the vanilla examples work.</p>
<h2 dir="auto">Context</h2>
<p dir="auto">Including the <code class="notranslate">next.config.js</code> - possibly this is factoring?</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const { env } = process;
const webpack = require('webpack');

module.exports = {
  exportPathMap () {
    // we fetch our list of posts, this allow us to dynamically generate the exported pages
    const all = require('./server/lib/docs');

    // transform the list of posts into a map of pages with the pathname `/post/:id`
    const pages = all.posts.docs.reduce((pages, post) =&gt;
      Object.assign({}, pages, {
        [`${post.url}`]: {
          page: '/_post',
          query: { slug: post.slug }
        }
      }),
    {});

    // combine the map of post pages with the home
    return Object.assign({}, pages, {
      '/': { page: '/' }
    });
  },

  webpack: function (config) {
    // this exposes everything on process.env.X
    const webpackEnv = Object.keys(env).reduce((acc, curr) =&gt; {
      acc[`process.env.${curr}`] = JSON.stringify(env[curr]);
      return acc;
    }, {});

    config.plugins.push(new webpack.DefinePlugin(webpackEnv));

    return config;
  }
};"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-kos">{</span> env <span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-s1">process</span><span class="pl-kos">;</span>
<span class="pl-k">const</span> <span class="pl-s1">webpack</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'webpack'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-smi">module</span><span class="pl-kos">.</span><span class="pl-c1">exports</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
  <span class="pl-en">exportPathMap</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-c">// we fetch our list of posts, this allow us to dynamically generate the exported pages</span>
    <span class="pl-k">const</span> <span class="pl-s1">all</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'./server/lib/docs'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-c">// transform the list of posts into a map of pages with the pathname `/post/:id`</span>
    <span class="pl-k">const</span> <span class="pl-s1">pages</span> <span class="pl-c1">=</span> <span class="pl-s1">all</span><span class="pl-kos">.</span><span class="pl-c1">posts</span><span class="pl-kos">.</span><span class="pl-c1">docs</span><span class="pl-kos">.</span><span class="pl-en">reduce</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">pages</span><span class="pl-kos">,</span> <span class="pl-s1">post</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span>
      <span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-en">assign</span><span class="pl-kos">(</span><span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-s1">pages</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
        <span class="pl-kos">[</span><span class="pl-s">`<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">post</span><span class="pl-kos">.</span><span class="pl-c1">url</span><span class="pl-kos">}</span></span>`</span><span class="pl-kos">]</span>: <span class="pl-kos">{</span>
          <span class="pl-c1">page</span>: <span class="pl-s">'/_post'</span><span class="pl-kos">,</span>
          <span class="pl-c1">query</span>: <span class="pl-kos">{</span> <span class="pl-c1">slug</span>: <span class="pl-s1">post</span><span class="pl-kos">.</span><span class="pl-c1">slug</span> <span class="pl-kos">}</span>
        <span class="pl-kos">}</span>
      <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">,</span>
    <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-c">// combine the map of post pages with the home</span>
    <span class="pl-k">return</span> <span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-en">assign</span><span class="pl-kos">(</span><span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-s1">pages</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
      <span class="pl-s">'/'</span>: <span class="pl-kos">{</span> <span class="pl-c1">page</span>: <span class="pl-s">'/'</span> <span class="pl-kos">}</span>
    <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span><span class="pl-kos">,</span>

  <span class="pl-en">webpack</span>: <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-s1">config</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-c">// this exposes everything on process.env.X</span>
    <span class="pl-k">const</span> <span class="pl-s1">webpackEnv</span> <span class="pl-c1">=</span> <span class="pl-v">Object</span><span class="pl-kos">.</span><span class="pl-en">keys</span><span class="pl-kos">(</span><span class="pl-s1">env</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">reduce</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">acc</span><span class="pl-kos">,</span> <span class="pl-s1">curr</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
      <span class="pl-s1">acc</span><span class="pl-kos">[</span><span class="pl-s">`process.env.<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">curr</span><span class="pl-kos">}</span></span>`</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-c1">JSON</span><span class="pl-kos">.</span><span class="pl-en">stringify</span><span class="pl-kos">(</span><span class="pl-s1">env</span><span class="pl-kos">[</span><span class="pl-s1">curr</span><span class="pl-kos">]</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
      <span class="pl-k">return</span> <span class="pl-s1">acc</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-s1">config</span><span class="pl-kos">.</span><span class="pl-c1">plugins</span><span class="pl-kos">.</span><span class="pl-en">push</span><span class="pl-kos">(</span><span class="pl-k">new</span> <span class="pl-s1">webpack</span><span class="pl-kos">.</span><span class="pl-c1">DefinePlugin</span><span class="pl-kos">(</span><span class="pl-s1">webpackEnv</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-k">return</span> <span class="pl-s1">config</span><span class="pl-kos">;</span>
  <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span></pre></div>
<h2 dir="auto">Your Environment</h2>

<table role="table">
<thead>
<tr>
<th>Tech</th>
<th>Version</th>
</tr>
</thead>
<tbody>
<tr>
<td>next</td>
<td>3.0.1-beta.13</td>
</tr>
<tr>
<td>node</td>
<td>8.1.0</td>
</tr>
<tr>
<td>OS</td>
<td>Mac 10.10.3 (14D136)</td>
</tr>
<tr>
<td>browser</td>
<td>Chrome Version 61.0.3156.0 (Official Build) canary (64-bit)</td>
</tr>
</tbody>
</table>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the <a href="https://github.com/zeit/next.js/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h2 dir="auto">Expected Behavior</h2>
<p dir="auto">When I'm deploying a production build, I should have minified javascript code in order to minimize file size and maximize performance.</p>


<h2 dir="auto">Current Behavior</h2>
<p dir="auto">My app.js is 529KB and not minified</p>


<h2 dir="auto">Steps to Reproduce (for bugs)</h2>


<ol dir="auto">
<li><code class="notranslate">next build</code></li>
<li><code class="notranslate">next start</code></li>
</ol>
<p dir="auto">OR</p>
<ol dir="auto">
<li><code class="notranslate">next build</code></li>
<li><code class="notranslate">next export</code></li>
</ol>
<h2 dir="auto">Context</h2>
<p dir="auto">I wanted to use next.js in order to have a lightning fast site as advertised but no minification kills that. I'm sure I'm missing something simple.</p>


<h2 dir="auto">Your Environment</h2>

<table role="table">
<thead>
<tr>
<th>Tech</th>
<th>Version</th>
</tr>
</thead>
<tbody>
<tr>
<td>next</td>
<td>4.1.1</td>
</tr>
<tr>
<td>node</td>
<td>8.4.0</td>
</tr>
<tr>
<td>OS</td>
<td>MacOS Sierra 10.12.6</td>
</tr>
<tr>
<td>browser</td>
<td>Chrome</td>
</tr>
<tr>
<td>etc</td>
<td>React and react-dom 16</td>
</tr>
</tbody>
</table>