Installations
npm install sprite-smith-loader
Developer
sunft1996
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
12.13.1
NPM Version
6.12.1
Statistics
2 Stars
13 Commits
1 Watching
15 Branches
1 Contributors
Updated on 14 Apr 2022
Total Downloads
Cumulative downloads
Total Downloads
7,458
Last day
-72.7%
3
Compared to previous day
Last week
0%
17
Compared to previous week
Last month
400%
45
Compared to previous month
Last year
-70.6%
244
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
1
sprite-smith-loader
:rocket: 中文文档点这里
Introduce
Sprite Smith loader is a tool for automatically generating CSS Sprites. You can use it in webpack. It will find all the_ sprite.png End picture and auto generate CSS Sprites and modify the corresponding CSS code.
supports CSS、SASS、LESS.
The picture should be in PNG format (do not directly change the picture suffix to PNG)
Getting Started
To begin, you'll need to install sprite-smith-loader:
npm install --save-dev sprite-smith-loader remove-file-webpack-plugin
Then add the plugin to your webpack config. And don't forget to add the file-loader or url-loader.
For example:
webpack.config.js
// add remove-file-webpack-plugin to clean sprites folders
const RemoveFileWebpackPlugin = require('remove-file-webpack-plugin');
module.exports = {
module: {
rules: [
{
test: /\.(png|jpe?g|gif)$/i,
loader: 'file-loader',
options: {
outputPath: 'images',
},
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader','sprite-smith-loader'],
},
],
},
plugins: [
new RemoveFileWebpackPlugin({
dirNames:["sprites"]
})
],
};
with SASS
const RemoveFileWebpackPlugin = require('remove-file-webpack-plugin');
module.exports = {
module: {
rules: [
{
test: /\.(png|jpe?g|gif)$/i,
loader: 'file-loader',
options: {
outputPath: 'images',
},
},
{
test: /\.(sass|scss|css)/,
use: ['style-loader', 'css-loader','sprite-smith-loader',"sass-loader"],
}
],
},
plugins: [
new RemoveFileWebpackPlugin({
dirNames:["sprites"]
})
],
};
Usage
Change the picture name to_ sprite.png End and reference it in CSS
.my_bg_1{
height: 100px;
width: 100px;
background: url('./demo1_sprite.png') 0px 0px;
background-size: 100px 100px;
}
.my_bg_2{
height: 100px;
width: 100px;
background: url('./demo2_sprite.png') -20px -20px;
background-size: 150px 150px;
}
After the CSS Sprites is generated, the loader will modify the background attribute in the CSS. In order to accurately calculate the converted background attribute, please follow the following specifications:
Css attribute name | isRequired | Description |
---|---|---|
height | true | Unit: PX |
width | true | Unit: PX |
background-size | true | Unit: PX |
background | true | Include image,position,repeat |
background-image | true | Included in background,picture name with _ sprite.png ending |
background-position | false | Included in background,format of value PX PX |
background-repeat | false | Included in background,must be no-repeat |
Other
If you have any questions, please create an issue on GitHub.
License
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/13 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
43 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-vh7m-p724-62c2
- Warn: Project is vulnerable to: GHSA-r9p9-mrjm-926w
- Warn: Project is vulnerable to: GHSA-434g-2637-qmqr
- Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m
- Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw
- Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p
- Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-w7q9-p3jq-fmhm
- Warn: Project is vulnerable to: GHSA-xvf7-4v9q-58w6
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq
- Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488
- Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr
- Warn: Project is vulnerable to: GHSA-566m-qj78-rww5
- Warn: Project is vulnerable to: GHSA-hwj9-h5mp-3pm3
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-hxcc-f52p-wc94
- Warn: Project is vulnerable to: GHSA-vx3p-948g-6vhq
- Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
Score
1.7
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to sprite-smith-loader
svg-sprite-loader
Webpack loader for creating SVG sprites
@nuxtjs/svg
Super simple svg loading module for Nuxt.js
@types/svg-sprite-loader
TypeScript definitions for svg-sprite-loader
external-svg-sprite-loader
A webpack loader and plugin that generate SVG sprites out of a collection of SVG files used in your JS and CSS files