Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change folder of "next export"

I've got following next.config.js

module.exports = {
  dir: "src",
  outDir: "./build"
};

When I run next build; next export; my static files end up in newly created out folder.

I thought outDir overwrites that, but apparently not. So is there a way to tell next to output static files into build folder as opposed to out

like image 611
Ilja Avatar asked Oct 31 '19 06:10

Ilja


People also ask

What is next export?

next export allows you to export your Next. js application to static HTML, which can be run standalone without the need of a Node. js server. It is recommended to only use next export if you don't need any of the unsupported features requiring a server.

How do I create a folder in next JS?

Launch the app and then choose your out/build/dist folder and then it will provide you a link, just navigate to the given link. next. js creates the . next directory instead of build .

What is static export?

The static export is an advanced OpenCms feature, that allows to gain an important performance improvement by mirroring pages and other resources into the real file system of the server.

Is next Js static?

Next. js has two forms of pre-rendering: Static Generation and Server-side Rendering. The difference is in when it generates the HTML for a page. Static Generation (Recommended): The HTML is generated at build time and will be reused on each request.

How do I use next export in NPM?

Update your build script in package.json to use next export: Running npm run build will generate an out directory. next export builds an HTML version of your app. During next build, getStaticProps and getStaticPaths will generate an HTML file for each page in your pages directory (or more for dynamic routes ).

Should I use next or next export?

It is recommended to only use next export if you don't need any of the unsupported features requiring a server. If you're looking to build a hybrid site where only some pages are prerendered to static HTML, Next.js already does that automatically. Learn more about Automatic Static Optimization and Incremental Static Regeneration.

Is it possible to export selected directory/folder contents from Windows XP context menu?

Back in the early days of Windows XP, I came across this really neat batch file that allowed users to export selected directory/folder contents listing to a txt file from Windows Explorer right-click context menu.

How do I use exportpathmap with next?

Open next.config.js and add the following exportPathMap config: Note: the query field in exportPathMap cannot be used with automatically statically optimized pages or getStaticProps pages as they are rendered to HTML files at build-time and additional query information cannot be provided during next export.


1 Answers

From the docs:

Absolute path to the out/ directory (configurable with -o or --outdir

You can run:

next export -o build/

to redirect the build to build directory.

like image 146
Agney Avatar answered Oct 23 '22 16:10

Agney