-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix vite.static endpoint #15
base: main
Are you sure you want to change the base?
Conversation
@sfermigier if you have time, would appreciate some eyes on this as this appears to be broken 🙏 See also #13, which I've realised after raising this PR is the exact same fix... |
Great job! I was about to create a pull request for this bug and realized you had already fixed it a few days ago. It seems @bonchondev accidentally changed the word vite in the endpoint to I’ve temporarily fixed the issue by defining a new URL rule in my project: # Initialize the Flask-Vite extension
app.config["VITE_AUTO_INSERT"] = True
app.config["VITE_FOLDER_PATH"] = "static"
vite = Vite(app)
app.add_url_rule(
"/assets/<path:filename>",
endpoint=f"{app.config['VITE_FOLDER_PATH']}.static",
view_func=vite.vite_static
) |
That's the same workaround I've had to do as well 😅 Yep good call on adding a test - will do that shortly 🙏 |
088a3c0
to
0593360
Compare
Unfortunately CI seems very broken and I'm not super familiar configuring tox or poetry, so not making easy progress. None of the historical CI runs still have their logs so it's a bit harder to see what should be happening to compare what's going wrong. Also no idea what that Will spend a bit more time but 🤷 Feels unfortunate. edit: alright got it sorted. |
0593360
to
28bcd0c
Compare
When the vite static endpoint is setup in vite.init_app, the endpoint name is hardcoded as `vite.static`: app.route( "/_vite/<path:filename>", endpoint="vite.static", host=self.vite_routes_host )(self.vite_static) The `make_static_tag` function, however, injects the `vite_folder_path` variable into the endpoint name: js_file_url = url_for(f"{vite_folder_path}.static", filename=js_file) css_file_url = url_for(f"{vite_folder_path}.static", filename=css_file) If you override the vite folder path from the default value of `vite`, then these URLs don't resolve. For example a vite folder path of `app/vite` would try to build URLs for `app/vite.static` - which doesn't exist.
CI is no longer working because the cache action is so out of dated. https://github.com/abilian/flask-vite/actions/runs/13392706813/job/37403982442 This bumps all of the actions to their latest major version.
1d48d0d
to
3e49a3a
Compare
When the vite static endpoint is setup in vite.init_app, the endpoint name is hardcoded as
vite.static
:The
make_static_tag
function, however, injects thevite_folder_path
variable into the endpoint name:If you override the vite folder path from the default value of
vite
, then these URLs don't resolve. For example a vite folder path ofapp/vite
would try to build URLs forapp/vite.static
- which doesn't exist.