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

vite-plugin-lucide-preprocess

v1.1.0

Published

![NPM Version](https://img.shields.io/npm/v/vite-plugin-lucide-preprocess) ![NPM Downloads](https://img.shields.io/npm/dw/vite-plugin-lucide-preprocess) ![NPM Type Definitions](https://img.shields.io/npm/types/vite-plugin-lucide-preprocess) ![NPM License]

Downloads

403

Readme

vite-plugin-lucide-preprocess

NPM Version NPM Downloads NPM Type Definitions NPM License

A Vite plugin to replace imports for Lucide icons.

What is this?

Motivation

If you want to import Lucide icons in your project, you can use two methods since this PR on Lucide (at least for lucide-svelte):

import { IconName } from "lucide-svelte";
// or
import IconName from "lucide-svelte/icons/icon-name";

While the first method is more convenient (and may be the one used by auto-import features in your editor), it is not tree-shakable. In fact, a single import from "lucide-<framework>" will import all icons, not ideal for performance and bundle size.

This plugin will replace the first method with the second one, so you can keep the convenience of the first method while benefiting from tree-shaking optimizations. “Correct” imports will be kept as-is.

[!NOTE] The plugin is primarily intended for lucide-svelte, but it should work with any Lucide package using Vite if they follow the same structure.

Credits and opinion

I got the idea from Phosphor Icons' optimizer. However, this plugin is written from scratch and is not based on the Phosphor one (even though the technique is essentially the same).

As it is a Vite plugin and not a Svelte one, it is more generic and can be used with any framework. Additionally, it doesn't suffer from the limitations of the Svelte plugin, preventing the Phosphor optimizer from working without disabling the native Vite optimizations of phosphor-svelte.

In my opinion, this should be a feature embedded in Lucide itself (lucide-svelte/preprocessor), but I don't know if it will ever be implemented. I opened an issue on the lucide-icons repository to discuss this.

Auto-updater

As of version 1.1.0, the plugin includes an auto-updater. It helps support the renamed and deprecated icons by automatically updating the plugin when necessary.

If you use a recently deprecated icon and can't make your build work, please wait for a few hours for the plugin to update itself. If the issue persists, please open an issue on this repository.

More information about the auto-updater can be found in https://github.com/WarningImHack3r/vite-plugin-lucide-preprocess/pull/6.

Installation

Install the plugin with your package manager of choice:

pnpm i -D vite-plugin-lucide-preprocess

Then, add it to your vite.config.js/.ts:

import { defineConfig } from "vite";
import lucidePreprocess from "vite-plugin-lucide-preprocess";

export default defineConfig({
  plugins: [lucidePreprocess(), ...]
});

[!WARNING] Make sure to add the plugin before any other preprocessors in the plugins array.

License

MIT