Skip to content
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

Parcel 2: Image Resizing Transformer #3737

Closed
devongovett opened this issue Nov 3, 2019 · 0 comments · Fixed by #4881
Closed

Parcel 2: Image Resizing Transformer #3737

devongovett opened this issue Nov 3, 2019 · 0 comments · Fixed by #4881

Comments

@devongovett
Copy link
Member

Create the @parcel/transformer-image-resize package. This should include a Transformer plugin that resizes images using the sharp library. It should accept options via query parameters to determine what size to resize the image to.

For example, you could reference an image like this to resize it to 200px wide:

<img src="./image.jpg?width=200" width="200">

This would also work anywhere images can be referenced, e.g. CSS or JS.

This transformer should be included in @parcel/config-default in a pipeline for *.{png,jpg,jpeg}. However, in order to improve development build performance, it should only run in production mode. This should be safe as long as users are using explicit sizes on their image tags in addition to their URLs. Also, if no query params are provided to the image url, the plugin should do nothing.

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

Successfully merging a pull request may close this issue.

2 participants