Skip to content

feat: Add support for base64 encoded data urls #30

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

Conversation

romainmenke
Copy link
Contributor

@romainmenke romainmenke commented Dec 7, 2022

Underlying issue :

  • this plugin only handles remote urls
  • postcss-import only handles local sources and only when @import statements are first and in order (following the CSS specification)

This makes it impossible to to use both plugins together without forcing a specific order of statements. Sometimes this forced order is not what is desired.


This change adds the option to store imported CSS back into an @import statement, but as a data url.

@import url(http://fonts.googleapis.com/css?family=Tangerine);

becomes :

@import url(data:text/css;base64,QGZvbnQtZmFjZSB7CiAgZm9udC1mYW1pbHk6ICdUYW5nZXJpbmUnOwogIGZvbnQtc3R5bGU6IG5vcm1hbDsKICBmb250LXdlaWdodDogNDAwOwogIHNyYzogdXJsKGh0dHA6Ly9mb250cy5nc3RhdGljLmNvbS9zL3RhbmdlcmluZS92MTcvSXVyWTZZNWpfb1NjWlpvdzRWT3hDWlpKLnR0ZikgZm9ybWF0KCd0cnVldHlwZScpOwp9Cg==);

decoded :

@font-face {
  font-family: 'Tangerine';
  font-style: normal;
  font-weight: 400;
  src: url(http://fonts.gstatic.com/s/tangerine/v17/IurY6Y5j_oScZZow4VOxCZZJ.ttf) format('truetype');
}

Combined with support for data urls in postcss-import it allows users to be more creative with their setups and plugin combinations.

@romainmenke
Copy link
Contributor Author

@unlight Any feedback would be awesome :)

@unlight unlight changed the title add support for base64 encoded data urls feat: Add support for base64 encoded data urls Dec 14, 2022
@unlight unlight merged commit 99be36e into unlight:master Dec 14, 2022
unlight pushed a commit that referenced this pull request Dec 14, 2022
github-actions bot pushed a commit that referenced this pull request Dec 14, 2022
# [7.2.0](v7.1.0...v7.2.0) (2022-12-14)

### Features

* Add support for base64 encoded data urls ([a70fc3c](a70fc3c)), closes [#30](#30)
@github-actions
Copy link

🎉 This issue has been resolved in version 7.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@romainmenke
Copy link
Contributor Author

thank you @unlight 🙇

@romainmenke romainmenke deleted the add-support-for-base64-encoded-data-urls--exuberant-glass-lizard-9977668808 branch December 14, 2022 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants