<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?q=is%3Aissue">issues</a> of this repository and believe that this is not a duplicate. There is a related issue <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="249896357" data-permission-text="Title is private" data-url="https://github.com/vercel/next.js/issues/2769" data-hovercard-type="issue" data-hovercard-url="/vercel/next.js/issues/2769/hovercard" href="https://github.com/vercel/next.js/issues/2769">#2769</a>, but it's slightly different and what was described there seems to be working now.</li>
</ul>
<h2 dir="auto">Expected Behavior</h2>


<p dir="auto">When I provide an absolute <code class="notranslate">distDir</code>, it works.</p>
<h2 dir="auto">Current Behavior</h2>


<p dir="auto">Because <code class="notranslate">path.join(dir, config.distDir)</code> is used everywhere, the path doesn't make sense and mkdirp fails (I guess other parts of Next.js would fail too if not for mkdirp failing first).</p>
<h2 dir="auto">Steps to Reproduce (for bugs)</h2>


<ol dir="auto">
<li>Create a custom server with the following configuration:</li>
</ol>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const app = next({
  dev,
  dir: __dirname,
  conf: {
    distDir: path.resolve('.foobar'),
  },
});"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">app</span> <span class="pl-c1">=</span> <span class="pl-en">next</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
  dev<span class="pl-kos">,</span>
  <span class="pl-c1">dir</span>: <span class="pl-s1">__dirname</span><span class="pl-kos">,</span>
  <span class="pl-c1">conf</span>: <span class="pl-kos">{</span>
    <span class="pl-c1">distDir</span>: <span class="pl-s1">path</span><span class="pl-kos">.</span><span class="pl-en">resolve</span><span class="pl-kos">(</span><span class="pl-s">'.foobar'</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></pre></div>
<ol start="2" dir="auto">
<li>Launch this server.</li>
</ol>
<h2 dir="auto">Context</h2>


<p dir="auto">I'm creating a tool that uses Next.js internally. As such, I'd like to keep stuff like <code class="notranslate">pages/</code> inside my package while putting the dist dir inside the project.</p>
<p dir="auto">Issue <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="249896357" data-permission-text="Title is private" data-url="https://github.com/vercel/next.js/issues/2769" data-hovercard-type="issue" data-hovercard-url="/vercel/next.js/issues/2769/hovercard" href="https://github.com/vercel/next.js/issues/2769">#2769</a> describes a situation where paths like <code class="notranslate">'../.foobar'</code> not working, but it doesn't seem to be the case now. That's why I can use the workaround of <code class="notranslate">path.relative(dir, path.resolve('.foobar'))</code>. But if <code class="notranslate">path.resolve(dir, config.distDir)</code> was used instead of <code class="notranslate">path.join(dir, config.distDir)</code>, other people could avoid this pitfall in the future.</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>6.0.2</td>
</tr>
<tr>
<td>node</td>
<td>8.9.3</td>
</tr>
<tr>
<td>OS</td>
<td>Win 10</td>
</tr>
</tbody>
</table>
<p dir="auto">I'm just going to leave this here, because it's a lot to type out, and it's quite possible it's user error. But seems like something is not working correctly with the imperative routing api / prefetch / client-side rendering:</p>
<p dir="auto"><a href="https://stackoverflow.com/questions/47701791/strange-imperative-onscroll-routing-behavior-in-next-js-only-rendering-on-serve" rel="nofollow">https://stackoverflow.com/questions/47701791/strange-imperative-onscroll-routing-behavior-in-next-js-only-rendering-on-serve</a></p>
<p dir="auto">thanks for taking a look :)</p>
<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>