helpscout / proxypack

🎭ProxyPack: Proxy Local Webpack Assets to your Production Domain
MIT License
6 stars 1 forks source link

Add cache and nested route parameters #11

Closed tjbo closed 5 years ago

tjbo commented 5 years ago

1 - this adds nested routes to localMappings in ProxyPack. This makes it possible to easily map a nested folder structure.

2 - this also adds a simple cache to reduce reads from local filesystem

For example if your images dir contained app1 and app2 and you wanted to map all these directories to the local filesystem with the following structure:

--|images|app1|dir1|thing.gif
--|images|app2|dir2|dir3|thing2.gif

You would use the following path to proxy all locally mapped assets in the ProxyPack plugin:

https://*.cloudfront.net/*/images/*folders/:image': `${__dirname}/site/images/`

Note: folders is a splat parameter. Splat parameters are like wildcards, only that they will capture the value of the identifier that comes after the .