更改“下一个导出”的文件夹

Ilj*_*lja 9 reactjs next.js

我有以下 next.config.js

module.exports = {
  dir: "src",
  outDir: "./build"
};
Run Code Online (Sandbox Code Playgroud)

当我运行next build; next export;我的静态文件时,它最终会出现在新创建的out文件夹中。

我以为会outDir覆盖那个,但显然不是。那么有没有办法告诉 next 将静态文件输出到build文件夹而不是out

Agn*_*ney 16

文档

out/ 目录的绝对路径(可使用 -o 或 --outdir 配置

你可以运行:

next export -o build/
Run Code Online (Sandbox Code Playgroud)

将构建重定向到build目录。

  • 更新了文档链接:https://nextjs.org/docs/api-reference/next.config.js/exportPathMap#customizing-the-output-directory (2认同)