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 🙏

© 2026 – Pkg Stats / Ryan Hefner

vue-sprite-plugin

v1.2.0

Published

## 描述

Downloads

12

Readme

vue-sprite-plugin

描述

vue单文件组件中的图片背景,通过vue-sprite-plugin插件处理后,可自动将项目中需要操作的图片合成雪碧图,并自动更新代码内容.

例如Home.vue代码如下:

<template>
   <div class="logo"></div>
   <div class="banner"></div>
</template>

<script lang="ts">
 ...
</script>
<style scoped lang="less">
  .logo{
    width:50px;
    height:50px;
    background-image: url('../../assets/images/logo.jpg?_sprite');
  }
  .logo{
    width:100px;
    height:100px;
    background-image: url('../../assets/images/banner.jpg?_sprite');
  }
</style>

只要代码中使用background-image做属性名,并且url后面加上后缀?_sprite,那么vue-sprite-plugin就会将此图片合成雪碧图.

目前插件只作用于生产环境,开发环境下不合成雪碧图.

vue-sprite-plugin处理后会自动将样式代码转化成下面形式:

<style scoped lang="less">
  .logo{
    width:50px;
    height:50px;
    background-image: url('../../assets/images/css-sprite.png');
    background-repeat:no-repeat;
    background-position:0 0;
  }
  .logo{
    width:100px;
    height:100px;
    background-image: url('../../assets/images/css-sprite.png');
    background-repeat:no-repeat;
    background-position:-50px 0;
  }
</style>

安装

项目下运行yarn add vue-sprite-plugin -D安装插件

配置

vue框架下的配置方式.在项目根目录vue.config.js添加如下配置.

const vueSpritePlugin = require("vue-sprite-plugin");

module.exports = {
    publicPath: './',
    chainWebpack:config =>{
        config.module
        .rule('vue')
        .test(/\.vue$/)
        .use("vue-sprite-plugin/src/loader/index")
        .loader("vue-sprite-plugin/src/loader/index")
        .end()

        config.plugin("vueSpritePlugin").use(vueSpritePlugin)
        .tap((args)=>{
            args = [
                {
                    filename:"css-sprite.png",
                    exclude:[]
                }];    
            return args;
        })
        .end();
    }
}

参数列表:

  • filename: 生成的雪碧图文件名,选填项,默认值为css-sprite.png.
  • exclude: 需要排除操作的文件列表,选填项,默认值为[].