Comments (9)
Hi,
You can have as many blueprints and template directories as you'd like but yeah this extension is only going to look in a single static directory to digest files. Mainly because in most applications you'd output your bundles to 1 specific directory (your static directory) and Flask will serve them from there. How you bundle those files are up to you.
from flask-static-digest.
I was able to compile, but tried different settings to blueprint, some cases the static_url_for method didn't match the filename to the file on the cache_manifest, other cases I just got a 404 loading the asset. I just wonder how I should config my blueprint.
Basically I was not able to set my blueprint this way:
my_blueprint = Blueprint(
"my_blueprint",
__name__,
static_folder="/static/my_blueprint",
static_url_path="/static/my_blueprint",
template_folder="../templates/my_blueprint"
)
and use static_url_for like that:
<link rel="stylesheet" href="{{static_url_for('my_blueprint.static', filename='css/style.css')}}">
the static_url_for does not match filename to cache_manifest and fallback to the file without md5 hash. If I change the above code to this:
<link rel="stylesheet" href="{{static_url_for('static', filename='my_blueprint/css/style.css')}}">
It works just fine. But I don't think its the best options. Do you know if I am doing some mistake?
from flask-static-digest.
The static_url_for
helper directly calls url_for
btw. It would be interesting if it behaved differently than url_for
. With your first example if you use url_for
instead (temporarily of course), do you get the same 404?
from flask-static-digest.
with url_for I get the normal file, without md5 hash. If I understood correctly this extensions uses the filename to make the match with cache_manifest.json and find the md5 version. My cache_manifest.json look like this:
{"my_blueprint/css/style.css": "my_blueprint/css/style-1688c8210b6509d702b1adb96bc4d0f3.css"}
This explains why this work:
<link rel="stylesheet" href="{{static_url_for('static', filename='my_blueprint/css/style.css')}}">
But this doesn't:
<link rel="stylesheet" href="{{static_url_for('my_blueprint.static', filename='css/style.css')}}">
I'm pretty sure that the problem is the way I think static_folder
and static_url_for
arguments for Blueprint
is wrong. So I will just stick without using my_blueprint.static
when using static_url_for. Thanks for your time!! :)
from flask-static-digest.
Yeah this extension will add the md5 hash but I was curious if {{ url_for('my_blueprint.static', filename='css/style.css' )}
worked in your case, in the sense that it didn't 404.
Flask's docs mention using my_blueprint.static
with url_for
will work as long as your Blueprint has a url_prefix
set.
from flask-static-digest.
I had no 404 with {{ url_for('my_blueprint.static', filename='css/style.css' )}
Well, thanks for the help, I will close the issue
from flask-static-digest.
No problem.
Sounds like I should add a FAQ item in the docs on how to reference static files within a Blueprint.
from flask-static-digest.
hi there, any updates on this one ? @ericsouza how did you compile files from blueptrints ?
from flask-static-digest.
hi there, any updates on this one ? @ericsouza how did you compile files from blueptrints ?
I endup splitting the frontend from the backend, so my flask application didn't have to deal with static files
from flask-static-digest.
Related Issues (20)
- Update python_requires to >=3.6 HOT 1
- Faster hashing with SHA1 or xxhash HOT 1
- Getting Permission Error on flask digest compile (Ubuntu 20.4) HOT 5
- static_url_for returning 500 HOT 17
- Blacklist Filter Array - Default Setting HOT 1
- README suggestion: how to use in Heroku HOT 8
- I think hash is long, can i go i short hash HOT 1
- a idea: dev envirienment with webpack HOT 5
- Option allows to minify static files HOT 1
- Statics no in FLASK_STATIC_DIGEST_HOST_URL root HOT 11
- has not working HOT 2
- Option to allow specify output folder for digested files? HOT 2
- Update references in .css and .js files to other files so they refer to the cache-busting filenames HOT 3
- Pretty print manifest file HOT 4
- There is no possibility to customize path to static_folder. HOT 2
- use a unique string in digested filenames to make the .gitignore line simpler HOT 1
- FLASK_STATIC_DIGEST_WHITELIST_FILTER HOT 3
- Adding a collect command to copy static assets (including from nested blueprints) to a target dir
- Flask Static Digest + Create React App HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flask-static-digest.