nickjj / flask-static-digest

Flask extension to help make your static files production ready by md5 tagging and gzipping them.
MIT License
157 stars 27 forks source link

Option to allow specify output folder for digested files? #24

Closed huynq2007 closed 2 years ago

huynq2007 commented 3 years ago

Hello

the digested files have been placing in the same folder as the original files. In case I use CDN, It's supposed that I only need to upload all digested files to my CDN server. as I don't want my original files also being upload to the CDN server.

Is there an option to allow to specify the output folder for digested files? (Imagine if static files are in many different folders, It could be quite a task...)

nickjj commented 3 years ago

Hi,

The output folder will be your Flask configured static_folder. Whether that ends up being the same as your original files is something you're in control of. For example in my apps I don't keep them in the same directory. I typically have the original files in an assets/ directory and then Webpack (or esbuild, etc.) processes the files and copies them to the Flask static_folder path.

You can also set FLASK_STATIC_DIGEST_HOST_URL = "https://cdn.example.com" to prefix all of your URL paths with your CDN's URL so they get served by your CDN. In a lot of cases CDNs are pull based, meaning they pull from your server the first time they're accessed and then after that they serve the file. In that case your original files need to be accessible.

If you're using a push based CDN you can send your files to that CDN as part of your deploy process which would be outside the scope of this extension, but this extension is set up to allow for that because at the end of the day it produces the files you would upload.

nickjj commented 2 years ago

Pretty sure my above comment addresses this, closing this. If it's still an issue feel free to reply.