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

image-sprite-webpack-plugin

v0.2.4

Published

Image Sprite Plugin for Webpack.

Downloads

84

Readme

image-sprite-webpack-plugin

npm

A webpack plugin that generates spritesheets from your stylesheets.

Input

  • width, height and background properties are mandatory to create a sprite.
  • Shorthand properties are recommended.
h1.logo {
    width: 240px;
    height: 80px;
    background: url(./img/logo.png) no-repeat 0 0;
    font-size: 0;
}

span.itemPicture {
    display: inline-block;
    background-image: url(./img/item-picture.png);
    background-repeat: no-repeat;
    background-position: 0 0;
    width: 36px;
    height: 36px;
}

Output

h1.logo {
  width: 240px;
  height: 80px;
  background: url(/css/sprite.png) no-repeat 0 -20px;
  /* background: url(/img/logo.png) no-repeat 0 0 */
  font-size: 0;
}

span.itemPicture {
  display: inline-block;
  background-image: url(/css/sprite.png);
  /* background-image: url(/img/item-picture.png) */
  background-repeat: no-repeat;
  background-position: -100px -90px;
  /* background-position: 0 0 */
  width: 36px;
  height: 36px;
}

Install

npm install -D image-sprite-webpack-plugin

Example

Production build

const ImageSpritePlugin = require('image-sprite-webpack-plugin');

new ImageSpritePlugin({
    commentOrigin: false,
    compress: true,
    extensions: ['gif', 'png'],
    indent: '',
    log: true,
    //outputPath: './public',
    outputFilename: 'css/sprite-[hash].png',
    padding: 10,
    suffix: '' + Date.now() // do not need to use it with a outputFilename's [hash].
})
git clone this repository
cd examples/webpack4-cssloader-single-chunk
npm i
npm run build

Webpack dev server

const ImageSpritePlugin = require('image-sprite-webpack-plugin');

new ImageSpritePlugin({
    commentOrigin: true,
    compress: false,
    extensions: ['gif', 'png'],
    indent: '  ',
    log: true,
    //outputPath: './public',
    outputFilename: 'css/sprite.png',
    padding: 10,
    suffix: ''
})
git clone this repository
cd examples/webpack4-cssloader-single-chunk
npm i
npm start

More Examples

NPM Commands in Examples

Each example has the following command.

  • Creates a production build.

    npm run build
  • Starts webpack-dev-server

    npm start
  • Creates a production build with node inspector. (with chrome://inspect/#devices)

    npm run build-debug
  • Starts webpack-dev-server with node inspector. (with chrome://inspect/#devices)

    npm run start-debug

Dependency

  • This plugin requires css-loader to handle CssModule.
  • It is also recommended that you use a file-loader to automatically move and access image resource files.

Compatibility

Options

|Name|Type|Default|Description| |:--|:--|:-----|:----------| |commentOrigin|{Boolean}|false|Shows the original image resource url with a comment.| |compress|{Boolean}|false|Compress the output css| |extensions|{Array}|['png', 'jpg', 'jpeg', 'gif']|File extensions to be converted with the spritesheets| |indent|{String}|' ' (2 spaces)|The indentation for css output source| |log|{Boolean}|true|Enable/disable message logging| |outputPath|{String}|webpack config's outputPath|Describes spritesheets file's output path| |outputFilename|{String}|'/sprite/sprite-[hash].png'|A sprite image filename| |padding|{Number}|0|Padding to use between images| |suffix|{String}|''|A suffix for outputFilename|

Bug Report

If you find a bug, please report to us posting issues on GitHub.

License

image-sprite-webpack-plugin is released under the MIT license.

Copyright (c) 2018 NAVER Corp.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.