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

aem-use-sprite-plugin

v1.0.4

Published

Webpack loader for creating SVG sprites

Downloads

55

Readme

AEM Use Sprite Plugin

npm version

A wrapper plugin for SVG Sprite Loader. This plugin generates a JavaScript Use-API JS file containing the dynamically generated path(s) of your SVG sprites which can be used in your HTL/Sightly files. This is very useful if your clientlibs are dynamically named or if you prefer to provide hashes with your sprites.

Example Configuration

// under plugins
plugins: [
  new AEMUseSpritePlugin({
    // This `spriteLoaderOptions` object is passed to the underlying Sprite Loader Plugin: https://github.com/JetBrains/svg-sprite-loader#plain-sprite
    spriteLoaderOptions: undefined,
    clientlibLocation: `FOLDER_CONTAINING_SPRITE`,
    outputUseFileLocation: `/apps/project/components/icon/icon.use.js`,
  }),
]

// under module.rules
{
  test: /\.svg$/,
  include: [path.resolve(__dirname, 'src/assets/sprite')],
  use: [
    {
      loader: 'svg-sprite-loader',
      options: {
        symbolId: '[name]',
        extract: true,
        // the sprite file must be under resources; [chunkname] here represents the clientlib (entry) name
        spriteFilename: `[chunkname]/resources/sprite-[hash].svg`,
      },
    },
    'svgo-loader',
  ],
},

Example Output File

use(function () {
  var path = parseInt(this.path, 10) || 0;
  var sprites = [
    "/apps/project/clientlibs/publish/resources/sprite-[hash].svg",
  ];

  return sprites[path];
});

Example Usage (in a page component)

customheaderlibs.html

<link
  data-sly-use.sprite="${'project/components/icon/icon.use.js'}"
  rel="preload"
  href="${sprite}"
  as="image"
/>

Example Usage (in a component)

icon.html

<!--/* 
  icon: selector containing the symbol id
  path: an optional integer describing which sprite path (if multiple) to use
*/-->
<sly
  data-sly-test.icon="${request.requestPathInfo.selectors[0]}"
  data-sly-test.path="${request.requestPathInfo.selectors[1] || '0'}"
/>
<svg data-sly-test="${icon}" data-sly-use.sprite="${'icon.use.js' @ path=path}">
  <use xlink:href="${sprite}#${icon}"></use>
</svg>