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

svelte-preprocess-unocss

v0.1.4

Published

Run UnoCSS in svelte-scoped mode via a svelte-preprocessor for use in component libraries

Downloads

13

Readme

svelte-preprocess-unocss

Run svelte-scoped-uno as a svelte preprocessor instead of as a Vite plugin to enable styles preprocessing in pipelines that don't use Vite, such as svelte-package.

Hopefully, someday svelte-package will heed applicable Vite plugins. Follow https://github.com/sveltejs/vite-plugin-svelte/issues/475 to see when this will be made possible. In the meantime this package was published to enable using svelte-scoped-uno in component libraries and other contexts that don't use Vite.

Setup

Install package

  • npm i -D svelte-preprocess-unocss

Add Preprocessor

// svelte.config.js
import adapter from '@sveltejs/adapter-auto'
import { vitePreprocess } from '@sveltejs/kit/vite';

+import { PreprocessUnocss } from 'svelte-preprocess-unocss'

+// If wanting to keep classes distinct during dev, turn your build/package script into `cross-env NODE_ENV=production svelte-kit sync && svelte-package`. Requires `cross-env` as a `devDependency`.
+const mode = process.env.NODE_ENV
+const prod = mode === 'production'

/** @type {import('@sveltejs/kit').Config} */
const config = {
  preprocess: [
    preprocess(),
+   PreprocessUnocss({
+     classPrefix: 'sk-', // default: 'spu-'
+     combine: prod,
+   }),
  ],

  kit: {
    adapter: adapter(),
  },
}

export default config

Add UnoCSS config

// unocss.config.ts
import { defineConfig, presetUno } from 'svelte-preprocess-unocss'

export default defineConfig({
  presets: [
    presetUno(),
  ],
})

All exports from unocss are re-exported from svelte-preprocess-unocss so there's no need to install unocss. This will avoid any breaking changes from unocss affecting your project.

Known Issues

Don't use --at-apply on classes that need global scoping like dark:___ as the .dark selector will be placed outside the global selector. For example, this will NOT work:

:global(.my-box) {
  --at-apply: dark:bg-red-700;
}

Instead just apply the class directly, like this:

<div class="dark:bg-red-700"></div>