Skip to content

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