Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Handle transformed assets URL #397

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

Merged
fjsj merged 1 commit into django-webpack:master from hostnfly:webpack-asset
Apr 2, 2024
Merged

Conversation

@batistadasilva
Copy link
Contributor

@batistadasilva batistadasilva commented Mar 29, 2024

Adding the following template tag

{% webpack_asset 'path/to/original/file' %}

Fixes #343

Depends on django-webpack/webpack-bundle-tracker#125


return '{0}{1}'.format(public_path, asset_name)

def get_asset(asset_name, config='DEFAULT'):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a docstring similar to the one from get_static, but clarify why this is different.

asset = next((x for x in assets if x.get("sourceFilename") == name), None)
if not asset:
asset = next((x for x in assets if x["name"] == name), None)
return asset
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should read like this:

 def get_asset_by_source_filename(self, name):
 files = self.get_assets()["assets"]
 return next((x for x in files if x.get("sourceFilename") == name), None)

Copy link
Member

@fjsj fjsj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, but please check suggestions. Thanks for the contribution!

Copy link
Contributor Author

@fjsj Thanks for the review!

Let me know if all changes fit the requirements

Adding the following template tag
```
{% webpack_asset 'path/to/original/file' %}
```
Fixes django-webpack#343
Depends on django-webpack/webpack-bundle-tracker#125 
Copy link
Member

@fjsj fjsj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks great.

"license": "MIT",
"devDependencies": {
"webpack": "^5.91.0",
"webpack-bundle-tracker": "github:hostnfly/webpack-bundle-tracker#assets-source-filenames",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change that after merge.

batistadasilva reacted with thumbs up emoji
@fjsj fjsj merged commit bf59f53 into django-webpack:master Apr 2, 2024
Copy link
Member

fjsj commented Apr 4, 2024
edited
Loading

Released at 3.1.0, thanks again @batistadasilva
If you have time, could you make a PR to update the README explaining how to use webpack_asset?
You can update this section to be mostly about webpack_asset: https://github.com/django-webpack/django-webpack-loader?tab=readme-ov-file#accessing-other-webpack-assets
And only mention webpack_static briefly, as I think the use case for webpack_asset is much more common.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@fjsj fjsj fjsj approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Not loading image processed by webpack correctly

AltStyle によって変換されたページ (->オリジナル) /