nuxt-spritesmith

A Nuxt(3) module for generate sprite image icons via spritesmith.
917
Install
npm install nuxt-spritesmith
Latest Version:2.1.2
Vue:3
License:MIT
Last Updated:Oct 23, 2026
Links: npm
Maintainer: elenh


nuxt-spritesmith

A Nuxt(3) module for generate sprite image icons via spritesmith

  • ✨  Release Notes

Features

  • Powered by spritesmith.
  • Support Multi sprite sheet generation.

Quick Setup

  1. Add nuxt-spritesmith dependency to your project
# Using pnpm
pnpm add -D nuxt-spritesmith

# Using yarn
yarn add --dev nuxt-spritesmith

# Using npm
npm install --save-dev nuxt-spritesmith
  1. Add nuxt-spritesmith to the modules section of nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    'nuxt-spritesmith'
  ],
  // custom nuxt-spritesmith options
  spritesmith: {
    engine: 'sharpsmith',
    engineOpts: {
      concurrentFileLimit: 4
    }
  }
})

You can also pass an engine constructor directly:

import SharpSmith from 'sharpsmith'

export default defineNuxtConfig({
  modules: ['nuxt-spritesmith'],
  spritesmith: {
    engine: SharpSmith,
  },
})
  1. Put your icons in ~/assets/sprites folder.

  2. Using your sprite icon.

<template>
  <div>
     <span class="sprite-some sprite-some--your-icon-name"></span>
  </div>
</template>

That's it! You can now use nuxt-spritesmith in your Nuxt app ✨

Custom engine

By default, the module uses the sharpsmith engine. You can explicitly select another installed engine, such as pixelsmith, by package name:

pnpm add -D nuxt-spritesmith sharpsmith
export default defineNuxtConfig({
  modules: ['nuxt-spritesmith'],
  spritesmith: {
    engine: 'sharpsmith',
    engineOpts: {
      concurrentFileLimit: 4,
    },
  },
})

The engine constructor can also be passed directly:

import SharpSmith from 'sharpsmith'

export default defineNuxtConfig({
  modules: ['nuxt-spritesmith'],
  spritesmith: {
    engine: SharpSmith,
  },
})

engineOpts is forwarded to the selected engine constructor. The engine must implement spritesmith-engine-spec@2.0.0.

Options

Key Default value Description
srcDir assets/sprites Sprite image source dir
outputDir public/sprites Sprite sheet output dir
engine sharpsmith Spritesmith engine package name or constructor
engineOpts - Options forwarded to the engine constructor
spriteConfig - Spritesmith generate CSS options
retina - Config for retina
prefix 'sprite-' Define sprite icon class name prefix
cssTemplate - Custom css template
enableDevWatch - Whether to enable watcher for the development env

The module scans the first-level directories under srcDir. For example, assets/sprites/payment/*.png generates public/sprites/payment.png and the corresponding CSS classes use the configured prefix.

When Retina support is enabled, files ending with @2x are grouped into a second sprite sheet, such as payment@2x.png, and CSS is generated with a device-pixel-ratio media query.

Development

# Install dependencies
pnpm install

# Generate type stubs
pnpm dev:prepare

# Develop with the playground
pnpm dev

# Build the playground
pnpm dev:build

# Run ESLint
pnpm lint

# Run Vitest
pnpm test
pnpm test:watch

# Release new version
npm run release

The test suite uses Vitest and Nuxt Test Utils. It covers SSR rendering, standard and Retina sprite generation, engine configuration, generated CSS, and cleanup of temporary fixture files.

Related Packages

@unocss/nuxt

Nuxt module for UnoCSS

3,181,743 18,982
nuxt-svg-icons

A module for Nuxt 4.6 that allows you to use your own SVG icons as a component,...

5,284
@vueuse/nuxt

VueUse Nuxt Module

16,311,630 22,398
nuxt-yup

yup implementation for nuxt

2,981 4
nuxt-componentsbook-module

This module provides a Storybook-like experience for Nuxt components

1,901 4

Version History

Version Released Vue License
2.1.2 ^3.0 MIT
2.1.1 ^3.0 MIT
2.1.0 ^3.0 MIT
1.2.1 ^3.0 MIT
1.1.0 ^3.0 MIT