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

Feat: add support for @import CSS-rule #86

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

dgorbash
Copy link

Added support for @import css-rule. It can help with inlining imported stylesheets such as Google Fonts.

The feature is disabled by default but can be enabled using the imports: true option.

Example:

css(
  {
    fileContent: '@import url('https://fonts.googleapis.com/css2?family=Open+Sans&display=swap')',
    imports: true
  }, 
  (err, content) => console.log(content)
)

Output:

@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 400;
  font-stretch: 100%;
  font-display: swap;
  src: url("data:font/woff2;base64,...) format('woff2');
}
...

Without imports: true the output will be:

@import url('data::text/css; charset=utf-8;base64,...');

Copy link
Owner

@jrit jrit left a comment

Choose a reason for hiding this comment

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

Thank you for the PR, could you please add or update a test that exercises the change?

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

Successfully merging this pull request may close these issues.

2 participants