How to exclude a folder from building next js but still read from it?
P粉478445671
2023-08-29 00:41:39
<p>I have a folder with many json files. I want to exclude it from the build as it increases the build size. But I also need to get the data from these files and it can't be stored in the database. Is there any way to achieve this? </p>
<p>I tried excluding the folder in next.config.js but couldn't find any changes</p>
First, you need to exclude the folders in
next.config.js
, assuming all the data you need to exclude is in thedata
folder:Secondly, you need to import the
data
folder usingrequire
in order to use json data: