I'm making a project with parcel and typescript. It works great, but for one library I'm using, I would need to host a bunch of .json-files at a fixed directory:
The files look as following:
index.html
index.ts
tiles/
| file.json
| file0.json
| subdirectory with *.json
In package.json
, I include them as parcel *.html tiles/*
(for start
) and parcel build index.html tiles/*
, but this results in the json files to be build into some .js file. I however need them to be served as is.
Any hints on how to tell parcel not to bundle them?
There is a npm-package doing exactly this: https://www.npmjs.com/package/parcel-plugin-static-files-copy
npm install -D parcel-plugin-static-files-copy
to install (for development only)
Then, in package.json
, add:
"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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With