npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

makestatic-inline-css

v1.1.20

Published

Transforms external stylesheets to inline styles

Downloads

7

Readme

Inline Css

Transforms external stylesheets to inline styles



Install

yarn add makestatic-inline-css

API

TransformInlineCss

For each HTML file inline transform stylesheets (link(rel="stylesheet")) into inline style elements.

Finds link elements in the HTML AST and converts them into style elements with the content of the external stylesheet inlined.

When the prune option is enabled this implementation will remove style rules whose selectors do not match elements in the document.

Note that the prune option whilst in use and appears to be working should be considered experimental.

.before

TransformInlineCss.prototype.before()

Initialize the list of matched resources used in the after hook to delete matched resources when the remove option is set.

.sources

TransformInlineCss.prototype.sources(file, context, options)

For each file with an HTML AST find all link elements that have the rel attribute set to stylesheet and have the href attribute set.

If the href attribute does not contain a protocol it is considered to reference a stylesheet that is available in the compilation asset list, in which case the stylesheet content from the referenced file is added as a text node of a style element and the link element is removed.

Supports absolute href attributes like /style.css and paths relative to the HTML document such as ../style.css.

Multiple external stylesheets that are being inlined will be concatenated into a single style element.

If the link element has a media attribute it must match the pattern specified using the media option, by default this is configured to match stylesheets that have a media query including one of:

  • all
  • screen
  • handheld

If a referenced stylesheet cannot be found in the compilation assets a warning is logged.

If watch mode is enabled for the compiler the remove option is disabled otherwise repeat compiles will not find the stylesheet to inline as it has been removed from the compilation assets.

  • file Object the file being processed.
  • context Object the processing context.
  • options Object the plugin options.
Options
  • remove Boolean=false delete matched resources.
  • prune Boolean=false remove rules that do not match the dom.
  • media RegExp pattern used to test the media attribute.

.after

TransformInlineCss.prototype.after(context)

Deletes matched resources from the compilation assets when the remove option has been enabled.

  • context Object the procesing context.

License

MIT


Created by mkdoc on March 13, 2017