简体   繁体   English

将文件移动到 Next.js 中的 src/pages 文件夹时,自定义 _app 和 _document 将被忽略

[英]Custom _app and _document get ignored when moving files to src/pages folder in Next.js

The Next.js documentation states, that the directory src/pages is an alternative to /pages . Next.js 文档指出,目录src/pages/pages pages 的替代品。 However, my custom _app.tsx and _document.tsx files, get ignored when the pages folder is moved into src.但是,当 pages 文件夹移动到 src 时,我的自定义_app.tsx_document.tsx文件会被忽略。

You can recreate this issue yourself, when creating an empty Next.js App, moving the pages folder into src and updating the import paths of the css files.您可以自己重新创建此问题,在创建一个空的 Next.js 应用程序时,将 pages 文件夹移动到 src 并更新 css 文件的导入路径。 The content of the index.tsx file will still be rendered, but modifications to the styles/globals.css , which is imported in the _app.tsx will have no effect. index.tsx文件的内容仍然会被渲染,但是在 _app.tsx 中导入的styles/globals.css_app.tsx将没有效果。

It is impossible to have a pages folder inside of src and outside of src at the same time, therefore preventing me to use src/pages in any app which needs a modificaton to the _app.tsx or _document.tsx .不可能同时在 src 和 src 之外有一个 pages 文件夹,因此阻止我在任何需要修改_app.tsx_document.tsx的应用程序中使用src/pages

Am I missing an important part of the documentation or does this work as intended?我是否遗漏了文档的重要部分,或者这是否按预期工作?

Changing your project folder structure or adding new _app / _document files can sometimes lead to caching issues.更改项目文件夹结构或添加新的_app / _document文件有时会导致缓存问题。

Delete the .next folder and restart your dev server, to ensure any caching done by Next.js doesn't get in the way.删除.next文件夹并重新启动您的开发服务器,以确保 Next.js 完成的任何缓存都不会妨碍您。

Really:deliverable:20,000,000,000 Rial IRAN真的:可交付:20,000,000,000 Rial IRAN

Seyed ARSHAM ATaSHZaR BankMellat:IR42 0120 0200 0000 8944 1880 20 Seyed ARSHAM ATaSHZaR BankMellat:IR42 0120 0200 0000 8944 1880 20

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM