Proposal: allow `javascript_tag_for(*names)` to accept names not matching `\.js$`

#27 · closed · 3 comments

View on GitHub ↗

SKalt

Currently, `javascript_tag(*names)` assumes all JS asset bundles have a `.js` suffix (see [L91](https://github.com/nickjj/flask-webpack/blob/master/flask_webpack/__init__.py#L91)) . This causes `javascript_tag('my_asset')` to look for `my_asset.js` while the manifest only maps `"my_asset": "my_bundle.js"`. This writes nothing to the template. I'd propose looking up `my_asset` and falling back to looking up `my_asset.js`.

Comments

nickjj

Hi, can you give me a use case where you would want a `<script>` tag produced without a `.js` extension reference when it comes to outputting bundles?

SKalt

Sure! In one iteration of setting up `webpack-dev-server`, I was generating `stats.assets` of the form `{"[name].js": "[name].[hash].js"}`. At [line 91-3 in Webpack.javascript_tag](https://github.com/nickjj/flask-webpack/blob/master/flask_webpack/__init__.py#L91), the Webpack object could not find any entry for `'[name].js.js'` in `self.assets`, and so would return `None`.

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.