Inconsistent behaviour relative to flask's `url_for('static', filename='x')`

#36 · closed · 2 comments

View on GitHub ↗

attack68

Just faced the problem whereby: `{{ asset_url_for('base.css') }}` renders `static/build/base.123.css` \ whilst \ `{{ url_for('static', filename='base.css')` renders `/static/base.css` The leading slash was important since I had a flask route which accepted arguments: ``` @web.route('/test/<int:val>') def test(val): return render_template('test.html') ``` when the css href was rendered by ``flask-webpack`` as `static/build/..` the lookup went to `/test/static/build/..` and gave a `404` error.\ Whilst `flask`s own version still went to `/static/base.css` and gave `200`. The fix was quite simple I have simply reverted to using the structure: `href="/{{ asset_url_for() }}"`, and I do note there is a mention of relative paths on the readme, albeit seemed more complicated that my simple case. However, it seems that the inconsistency with `flask`s own version is likely to trip up others as it did me, and I wonder where the absolute path is not more frequently used. Having an option to preappend a static path or just `/` in the config settings? Perhaps I have missed a trick, but then this issue just serves to highlight how to make the package more amenable to layman consumers!!

Comments

attack68

And on second inspection I found that adding a `seed` to `ManifestPlugin` did the trick: new ManifestPlugin({ seed: { publicPath: '/' }, Still I wonder whether this will help someone down the line. Can be closed I believe..

nickjj

Hi, Sorry for the long delay. This project is about to get archived and will no longer be supported. A new project is taking its place at: https://github.com/nickjj/flask-static-digest This new project is much easier to use, and will not only work with Webpack but it will work with any (or no) asset build tools. It's completely standalone.