如何在另一个文件夹中设置.next-folder?
How to set .next-folder in another folder?
我的页面文件夹在 /client 文件夹中,我希望 .next 文件夹在项目的根目录中。
我有一个结构如下的项目:
我将 pages 文件夹放在 ./client/pages 下。理想情况下,我想将 .next 文件夹放在项目的根目录中。
可以这样做吗?
您可以使用 next.config.js 文件来指定构建的输出。
我喜欢将我的文件夹命名为 _next 以简化路由。
module.exports = {
distDir: '_next',
};
所以你可以让你的路径通过目录遍历一级:
module.exports = {
distDir: '../.next',
};
虽然我建议您不要使用 .next 名称,而是使用下划线,但这将解决生产中的许多难题。
module.exports = {
distDir: '../_next',
};
更好的解决方案是使用像 Nginx 这样的代理来为您处理路由。因此,将您的 _next 文件夹保留在客户端目录中,并将根路径设置为您的客户端文件夹。
我的页面文件夹在 /client 文件夹中,我希望 .next 文件夹在项目的根目录中。
我有一个结构如下的项目:
我将 pages 文件夹放在 ./client/pages 下。理想情况下,我想将 .next 文件夹放在项目的根目录中。
可以这样做吗?
您可以使用 next.config.js 文件来指定构建的输出。
我喜欢将我的文件夹命名为 _next 以简化路由。
module.exports = {
distDir: '_next',
};
所以你可以让你的路径通过目录遍历一级:
module.exports = {
distDir: '../.next',
};
虽然我建议您不要使用 .next 名称,而是使用下划线,但这将解决生产中的许多难题。
module.exports = {
distDir: '../_next',
};
更好的解决方案是使用像 Nginx 这样的代理来为您处理路由。因此,将您的 _next 文件夹保留在客户端目录中,并将根路径设置为您的客户端文件夹。