gpt4 book ai didi

json - 如何在不 bundle 裹的情况下提供带有包裹的 j​​son 文件?

转载 作者:行者123 更新时间:2023-12-04 00:16:50 26 4
gpt4 key购买 nike

我正在用包裹和 typescript 制作一个项目。它很好用,但对于我正在使用的一个库,我需要在固定目录中托管一堆 .json 文件:
文件如下所示:

index.html
index.ts
tiles/
| file.json
| file0.json
| subdirectory with *.json
package.json , 我将它们包括为 parcel *.html tiles/* (对于 start )和 parcel build index.html tiles/* ,但这会导致 json 文件被构建到一些 .js 文件中。但是,我需要按原样提供它们。
关于如何告诉包裹不要捆绑它们的任何提示?

最佳答案

有一个 npm-package 正是这样做的:https://www.npmjs.com/package/parcel-plugin-static-files-copynpm install -D parcel-plugin-static-files-copy安装(仅用于开发)
然后,在 package.json , 添加:

"staticFiles": {
"staticPath": [
{
"staticPath": "tiles", -- copy all files from this directory at the root from your project...
"staticOutDir": "tiles/" -- ... to this directory in dist/, so it becomes dist/tiles/<files>
}
]
}

```

Note that you have to define a `staticPath` in the list `staticPath`, this is a bit confusing at first.

关于json - 如何在不 bundle 裹的情况下提供带有包裹的 j​​son 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63102658/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com