Gathering detailed insights and metrics for gulp-css-spritus
Gathering detailed insights and metrics for gulp-css-spritus
Gathering detailed insights and metrics for gulp-css-spritus
Gathering detailed insights and metrics for gulp-css-spritus
npm install gulp-css-spritus
Typescript
Module System
Node Version
NPM Version
52.4
Supply Chain
80.4
Quality
66.2
Maintenance
50
Vulnerability
94.8
License
JavaScript (85.99%)
CSS (14.01%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
7,831
Last Day
5
Last Week
8
Last Month
74
Last Year
416
MIT License
1 Stars
40 Commits
1 Watchers
2 Branches
1 Contributors
Updated on Jan 06, 2019
Minified
Minified + Gzipped
Latest Version
1.7.2
Package Id
gulp-css-spritus@1.7.2
Unpacked Size
25.00 kB
Size
7.17 kB
File Count
7
NPM Version
6.5.0
Node Version
10.14.2
Cumulative downloads
Total Downloads
Last Day
400%
5
Compared to previous day
Last Week
-61.9%
8
Compared to previous week
Last Month
335.3%
74
Compared to previous month
Last Year
-31.5%
416
Compared to previous year
Parses your CSS to find the sprites and then creates, saves and compresses
Easy to use with your CSS, SASS (SCSS) and others
The sprite is stored only those images that you use
For PostCSS use postcss-spritus
npm install gulp-css-spritus --save
1.icon { 2 background-image: spritus-url("assets/images/icons/*.png"); 3 background-size: spritus-size("assets/images/icons/*.png"); 4} 5 6.icon-google { 7 background-position: spritus-position("assets/images/icons/*.png", "google.png"); 8 height: spritus-height("assets/images/icons/*.png", "google.png"); 9 width: spritus-width("assets/images/icons/*.png", "google.png"); 10} 11 12/** OR **/ 13 14.icon { 15 spritus: each("assets/images/icons/*.png") 16} 17
1$icons-sprite: "assets/images/icons/*.png"; 2 3.icon { 4 background-image: spritus-url($icons-sprite); 5 background-size: spritus-size($icons-sprite); 6} 7 8.icon-google { 9 background-position: spritus-position($icons-sprite, "google.png"); 10 height: spritus-height($icons-sprite, "google.png"); 11 width: spritus-width($icons-sprite, "google.png"); 12} 13 14.icon-vk { 15 background-position: spritus-position($icons-sprite, "vk"); 16 height: spritus-height($icons-sprite, "vk"); 17 width: spritus-width($icons-sprite, "vk"); 18} 19.icon-twitter { 20 spritus:phw($icons-sprite, "twitter"); 21}
1var gulp = require("gulp"); 2var sass = require("gulp-sass"); 3var spritus = require("gulp-css-spritus"); 4 5//SCSS 6gulp.task("scss", function () { 7 return gulp.src("./assets/scss/app.scss") 8 .pipe(sass().on("error", sass.logError)) 9 .pipe(spritus({ 10 imageDirSave: "public/images/", 11 imageDirCSS: "../images/", 12 })) 13 .pipe(gulp.dest("./public/css")); 14}); 15 16//CSS 17gulp.task("css", function () { 18 return gulp.src("./assets/css/main.css") 19 .pipe(spritus({ 20 imageDirSave: "public/images/", 21 imageDirCSS: "../images/", 22 })) 23 .pipe(gulp.dest("./public/css")); 24});
1var gulp = require("gulp") 2 , merge = require("merge-stream") 3 , sass = require("gulp-sass") 4 , spritus = require("gulp-css-spritus") 5 , imagemin = require("gulp-imagemin") 6 , cssnano = require("gulp-cssnano") 7 , imageminPngquant = require("imagemin-pngquant") 8 , imageminMozjpeg = require("imagemin-mozjpeg") 9 , buffer = require("vinyl-buffer") 10 ; 11 12gulp.task("scss", function () { 13 var spritus = gulp.src("./scss/**/*.scss") 14 .pipe(sourcemaps.init()) 15 .pipe(sass().on("error", sass.logError)) 16 .pipe(spritus({ 17 padding: 2, 18 algorithm: "top-down", 19 saveImage: false, 20 withImagemin: false, 21 withImageminPlugins: null, 22 imageDirCSS: "../images/", 23 imageDirSave: "public/images/" 24 })); 25 26 var stream_css = spritus.css 27 .pipe(cssnano()) 28 .pipe(sourcemaps.write()) 29 .pipe(gulp.dest("./public/css")); 30 31 32 var stream_img = spritus.img 33 .pipe(buffer()) 34 .pipe(imagemin( 35 [ 36 imageminMozjpeg(), 37 imageminPngquant({ 38 quality: "60-70", 39 speed: 1 40 }) 41 ] 42 )) 43 .pipe(gulp.dest("./public/images")); 44});
The path relative to the root of the script
1$sprite: "assets/images/icons/*.png";
Method | Description |
---|---|
spritus-url($sprite); | is replaced by a relative link to the sprite url("../images/icons.png") |
spritus-size($sprite); | is replaced with the size of the sprite |
spritus-position($sprite, "%file_name%"); | is replaced by the position of the image in the sprite |
spritus-height($sprite, "%file_name%"); | is replaced by height in pixels |
spritus-width($sprite, "%file_name%"); | is replaced by width in pixels |
spritus:phw($sprite, "%file_name%"); | is replaced by the position, height and width of the image in sprite background-position: 0px 60px;height:30px;width:30px; |
spritus:each($sprite); | is replaced by all sprite image. See example below |
%file_name%
— may be full filename.png
or only basename filename
without extension
How does spritus:each($sprite);
1/** example 1 **/ 2.myprefix { 3 spritus:each("assets/images/icons/*.png") 4} 5 6/** example 2 **/ 7i.prefix { 8 display:none; 9 spritus:each("assets/images/icons/*.png") 10}
1/** example 1 **/ 2.myprefix-google { 3 background-position: 0px 26px;height: 26px;width: 26px; 4} 5.myprefix-twitter { 6 background-position: 0px 42px;height: 26px;width: 26px; 7} 8... 9 10/** example 2 **/ 11i.prefix-google { 12 display:none; 13 background-position: 0px 26px;height: 26px;width: 26px; 14} 15i.prefix-twitter { 16 display:none; 17 background-position: 0px 42px;height: 26px;width: 26px; 18} 19...
$icons-sprite: "assets/images/icons/*.png?padding=30&algorithm=diagonal&name=newdir/newicons";
1// ... 2.pipe(spritus({ 3 padding: 2, 4 searchPrefix: "spritus", 5 algorithm: "top-down", 6 saveImage: true, 7 withImagemin: true, 8 withImageminPlugins: [ 9 imageminPngquant({ 10 quality: "60-70", 11 speed: 1 12 }) 13 ], 14 imageDirCSS: "../images/", 15 imageDirSave: "public/images/" 16})) 17// ...
padding
The amount of transparent space, in pixels, around each sprite. Defaults to 2
saveImage
Save or don't save. Defaults to true
withImagemin
Compression of the sprite using imagemin. Defaults to true
withImageminPlugins
Specify what to use plugins for. Defaults to [require('imagemin-pngquant')({quality: "60-70",speed: 1})]
imageDirCSS
Relative URL (background-image) which is replaced in position in your CSS. Defaults to ../images/
imageDirSave
The path where to save the sprites relative to the root of the script. Defaults to public/images/
searchPrefix
If you want to use a different prefix, then this option is for you.
Defaults to spritus
gulpfile.js
1// ... 2.pipe(spritus({ 3 searchPrefix: "myprefix" 4})) 5// ...
Now you can now use
SCSS
1.icon { 2 background-image: myprefix-url($icons-sprite); 3 background-size: myprefix-size($icons-sprite); 4} 5 6.icon-google { 7 background-position: myprefix-position($icons-sprite, "google.png"); 8 height: myprefix-height($icons-sprite, "google.png"); 9 width: myprefix-width($icons-sprite, "google.png"); 10}
algorithm
Images can be laid out in different fashions depending on the algorithm. We use layout to provide you as many options as possible. . Defaults to top-down
.At the time of writing, here are your options for algorithm
:
top-down | left-right | diagonal | alt-diagonal | binary-tree |
---|---|---|---|---|
![]() | ![]() | ![]() | ![]() | ![]() |
More information can be found in the layout documentation:
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/27 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-02-10
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 More