secundant / neodx

A collection of frontend-focused tools aimed at enhancing your development experience
MIT License
80 stars 6 forks source link

`@neodx/svg` - Add built-in `vite` plugin #59

Closed secundant closed 1 year ago

secundant commented 1 year ago

Currently, I've developed the @neodx/svg package, a flexible CLI for SVG sprite generation. Compared to static/inline/svgr/loaders methods, this tool significantly improves developer experience, reduces bundle size and build time, and enhances browser performance, among other benefits. However, a CLI alone isn't sufficient; we need a solution integrated with our build process:

To address these requirements, I plan to create a plugin that covers these functionalities seamlessly.

// vite.config.ts
import { defineConfig } from 'vite';
import { viteSvgPlugin } from '@neodx/svg/vite';

export default defineConfig({
  plugins: [
    viteSvgPlugin({
      root: 'src/shared/assets/icons',
      group: true,
      output: 'public/icons',
      definitions: 'src/shared/ui/icon/icons.gen.ts'
    })
  ]
});

As an initial goal, I planned to add support for vite only, but I will also explore opportunities to support the entire web ecosystem using unplugin.