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

@ufhealth/gutenberg-scope-loader

v1.1.0

Published

Automatically add WordPress Gutenberg editor scope to stylesheets

Downloads

12

Readme

Gutenberg Scope Loader

Build Status Coverage Status

Automatically prefix selectors in any stylesheet with the Gutenberg editor's scope selector .editor-block-list__block. This allows you to write editor stylesheets without uber-specific selectors and not have to worry about specificity issues. It also allows your editor stylesheets to follow the same Webpack pipeline as your other stylesheets, so you can have nice things like hot-reloading.

But, why?

Gutenberg recently added built-in support for a similar behavior, which is enabled with the editor-styles theme feature. The difference is, the editor's built-in method involves the browser (your user) parsing and altering the selectors in a stylesheet at runtime, which can be an incredibly expensive process if the file is large. It also has no support for style injection or hot reloading, which gives a lot of developers a sad.

This loader leverages postcss within your build process to perform this task. This means your stylesheet already has those selectors in place when it's loaded, and the your user's browser doesn't have to do any work. Plus, if you're already using HMR on the front-end, you can use it on the back-end too just as easy, and get hot-reloaded stylesheets in your editor. Nice.

Ok, so how do I use it?

Install:

yarn add -D @ufhealth/gutenberg-scope-loader

Add to your Webpack config:

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.css$/, // Or .scss or whatever
        use: [
          'style-loader',
          {
            loader: '@ufhealth/gutenberg-scope-loader',
            options: {
              files: [
                /editor\.css$/
              ]
            }
          },
          // Other loaders and stuff
        ]
      }
    ]
  }
}

Loader options

files

Type: Array (required-ish)
Default: []

An array of strings or regular expressions; only the source files matching these paths/patterns will have their contents prefixed. This means the loader can be included in your main stylesheet loader chain, but will only touch the necessary sources. If you don't provide any patterns to match, the loader just won't do anything.

selector

Type: string
Default: .editor-block-list__block

The editor scope selector. You shouldn't need to change this, unless Gutenberg changes the selector in their source and you realize it before we do.

sourceMap

Type: boolean
Default: false

Whether to include and transform a source map.

Now what?

I dunno man, you take it from here—the world is your oyster.