Next.js Discord

Discord Forum

How to stop `next build` bundling an absolute path referenced in source code

Answered
Porcelaine posted this in #help-forum
Open in Discord
PorcelaineOP
We're creating a standalone build of a Next.js app, but the .next/standalone directory contains a directory that we don't want to be included.

The reason it seems to be included is that one of our files contains an absolute path to the directory (like {path.resolve()}/blah). If we remove those paths from our source, they no longer get bundled into the standalone directory.

I assume Webpack is seeing this absolute path and assuming it must be included in the bundle. Is there a recommended way to tell Webpack to ignore this path?

Note, we're not requireing or importing the path, so I'm not sure why Webpack thinks it needs to be included in the bundle in the first palce.

3 Replies