M
M
mydarck2017-04-20 11:46:47
Adobe Photoshop
mydarck, 2017-04-20 11:46:47

Gulp-svg-sprites - multiple sprites, how to do?

I am using gulp-svg-sprites to generate svg sprites. At the output I get .css, which is converted into a .scss file with sprite styles and .svg sprite, respectively. Scss is subsequently compiled into a common file with styles and sent to the project in this form. This .scss file has the following code:

.icon:before {
    content:' ';
    vertical-align:middle;
    display: inline-block;
    background-image: url("../svg-res/svg-sprite.svg");
    background-repeat: no-repeat;
    background-size: 6.4em 6.4em;
}

Those. all elements with class .icon are assigned background-image: url("../svg-res/svg-sprite.svg"); and when it comes to a single sprite for the entire site, there are no problems, but when it becomes necessary to create several sprites, then each subsequent .scss file with sprite styles that will be connected to a common file will also have the .icon class and responsibly interrupt this class . There is also a problem with the unique names of the .scss files themselves.
From this follows the task (task): How to get several directories with .svg files stored in them on the basis of gulp-svg-sprites, and at the output get all the same folders but already with sprites formed in them, the scss-sprite folder with styles having unique names (it is desirable to take the names according to the name of the directory in which the elements that form the sprite are stored) and change the .icon styles themselves to be unique for each sprite?
So far I haven't been able to automate this. If anyone has faced a similar problem, please share your ideas.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Proskurin, 2018-05-02
@AleksandrB

You create a vector object and put a picture there, you also draw at an angle. If Photoshop is older, you draw a vector object in the same way and use a mask to cut out a similar shape from the picture.
UPD: For example:
1. Create a shape, paste the image on top prntscr.com/jcxgrj
2. The shape should be under the layer with the picture, right-click on the picture -> create a clipping mask prntscr.com/jcxh7o
3. Result: prntscr.com /jcxhd4

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question