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

@uniformdev/sanity-plugin-uniform-optimize

v19.59.0

Published

Sanity plugin for Uniform Optimize

Downloads

76

Readme

Development notes

Build

  • pnpm build - builds icons, JS modules, and CSS.

CSS

This package uses Tailwind CSS. Run pnpm build:css to compile the CSS file, which will run PostCSS with the Tailwind plugin against all .css files in the assets folder. The compiled CSS will be output to dist/assets/[filename].css.

When Sanity Studio imports the JS modules exported by our plugin, the Sanity Studio bundler will also automatically import any CSS files that our code imports, e.g. import '../dist/assets/optimize.css';

NOTE: be sure to set NODE_ENV=production if you want PostCSS to purge unused CSS.

Icons

If you want to import SVG icons as components in your code, do the following:

  • Add the the SVG icon to the src/assets folder
  • Run pnpm build:icons

This will generate React components for every SVG icon in the src/assets folder. You can then import the icons in other React components, e.g. import MyIcon from '../assets/MyIcon';.

Ideally, we could have import MyIcon from '../assets/my-icon.svg in our code and the SVG icon would automatically be converted to a React component at build time and our source code would be transformed to import the component. However, we're not using a bundler so it becomes challenging because we can't "hook" into the TypeScript build/transpile process. We could introduce a build tool like ESBuild or @babel/typescript and stop using tsc, but those options more tooling/overhead. We could also potentially use something like ttypescript (https://github.com/cevek/ttypescript) to create babel-esque plugins for TypeScript, but who knows how reliable that is and if we'd run into any issues in CI/testing.

So, for now, icons are somewhat of a manual process.

CommonJS

No CommonJS modules are exported from this package as the package is intended to be consumed by Sanity Studio and not used during SSR.

Why esbuild?

Sanity does not transpile modules imported from node_modules, so if you have a dependency on any packages in the node_modules that need to be transpiled to work in Sanity's environment, you are not in luck.

Therefore, we use esbuild to build and bundle our plugin so that all relevant dependencies are included in the bundle and transpiled accordingly. TypeScript tsc does not have bundling capabilities, but we still use it for type-checking during the build process, because esbuild does not perform type-checking.