All Projects β†’ naver β†’ image-sprite-webpack-plugin

naver / image-sprite-webpack-plugin

Licence: MIT license
A webpack plugin that generates spritesheets from your stylesheets.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to image-sprite-webpack-plugin

config-webpack-plugin
πŸ’« Merge one or more configuration files together with environment variables too.
Stars: ✭ 18 (-33.33%)
Mutual labels:  webpack-plugin
bettertext.css
Improved default typography for naked HTML or Markdown-generated content.
Stars: ✭ 36 (+33.33%)
Mutual labels:  stylesheet
webpack-stats-diff-plugin
Webpack plugin for reporting changes in bundle sizes across builds
Stars: ✭ 63 (+133.33%)
Mutual labels:  webpack-plugin
spritesmith-texturepacker
Export TexturePacker compatible sprite sheets with spritesmith
Stars: ✭ 11 (-59.26%)
Mutual labels:  spritesmith
remove-files-webpack-plugin
A plugin for webpack that removes files and folders before and after compilation.
Stars: ✭ 48 (+77.78%)
Mutual labels:  webpack-plugin
loading-screen
πŸš₯Loading screen for webpack plugin inspired by Nuxt.js's loading screen
Stars: ✭ 56 (+107.41%)
Mutual labels:  webpack-plugin
qn-webpack
Qiniu webpack plugin (七牛 Webpack 插仢)
Stars: ✭ 39 (+44.44%)
Mutual labels:  webpack-plugin
css-chunks-html-webpack-plugin
Injecting css chunks extracted using extract-css-chunks-webpack-plugin to HTML for html-webpack-plugin
Stars: ✭ 22 (-18.52%)
Mutual labels:  webpack-plugin
webpack-alioss-upload-plugin
A flexible webpack plugin to upload files to aliyun oss, which supports multiple optional upload methods and parameters.
Stars: ✭ 14 (-48.15%)
Mutual labels:  webpack-plugin
ScienceNotebooks
Collection of tools and stylesheet for scientific writting and learning (through Anki)
Stars: ✭ 43 (+59.26%)
Mutual labels:  stylesheet
bower-resolve-webpack-plugin
Offers an enhanced bower support for enhanced-resolve plugin.
Stars: ✭ 12 (-55.56%)
Mutual labels:  webpack-plugin
chicio.github.io
πŸ‘» Fabrizio Duroni (me πŸ˜„) personal website. Created using GatsbyJS, Styled Components, Storybook, Typescript, tsParticles, GitHub pages, Github Actions, Upptime.
Stars: ✭ 20 (-25.93%)
Mutual labels:  webpack-plugin
fast-css-loader
blazingly fast css loader for webpack
Stars: ✭ 21 (-22.22%)
Mutual labels:  css-loader
warnings-to-errors-webpack-plugin
a webpack plugin that can recognize every warning as errors.
Stars: ✭ 17 (-37.04%)
Mutual labels:  webpack-plugin
monaco-editor-esm-webpack-plugin
No description or website provided.
Stars: ✭ 25 (-7.41%)
Mutual labels:  webpack-plugin
mock-webpack-plugin
A webpack plugin that starts a json mock server
Stars: ✭ 21 (-22.22%)
Mutual labels:  webpack-plugin
CustomWebCheckbox
An example of a make checkbox design on the web.
Stars: ✭ 12 (-55.56%)
Mutual labels:  stylesheet
prettier-eslint-webpack-plugin
Webpack plugin for prettier-eslint which ESLint's settings is set to JavaScript Standard Style
Stars: ✭ 24 (-11.11%)
Mutual labels:  webpack-plugin
size-plugin-bot
A Github bot for size-plugin
Stars: ✭ 76 (+181.48%)
Mutual labels:  webpack-plugin
DoodleCSS
A simple hand drawn HTML/CSS theme
Stars: ✭ 850 (+3048.15%)
Mutual labels:  stylesheet

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. image
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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].