問題描述
我有一個用例,我在我的公共文件夾中動態存儲一個 pdf 文件.public/print-preview/
.
I have a use case where I'm dynamically storing a pdf file in my public folder.
public/print-preview/
.
這里的問題是應用程序重新加載,并且在創建和存儲此類文件后狀態會丟失.
The issue here is that the application reloads and the state gets lost after such a file was created and stored.
我怎樣才能排除這樣的文件夾被監視?有沒有辦法在不彈出的情況下實現這一點?
How can I exclude such a folder from being watched? And is there a way to achieve this without ejecting?
推薦答案
來自 https://github.com/facebook/create-react-app/issues/2541:
我認為我們不會這樣做,因為似乎人們通常不會這樣做使用公用文件夾進行上傳.而且它在生產中不起作用無論如何.
I don't think we'll do this as it seems like people generally don't use public folder for uploads. And it wouldn't work in production anyway.
我建議使用單獨的服務器(無論如何您都需要)并且用于圖像上傳的單獨文件夾,并讓應用程序從不同的主機/端口(就像它在生產中一樣,例如從CDN).
I would recommend to use a separate server (which you need anyway) and separate folder for image uploads, and have the app load images from a different host/port (just like it would in production, e.g. from a CDN).
這篇關于create-react-app 排除文件夾觸發重新加載的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!