Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

181
Visualizações
Transform svg icons in js

I have a library of SVG icons (files) that I need to put in js variables that can then be imported after a build in other parts of the application. This process will be performed by a gulp script that must convert the svgs. The scenario can be resumed with the following example:

Folders:

dist/
 |_icons/
src/
 |_svgs/
gulpfile.js
<!-- svgs/MyIcon.svg -->
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path fill-rule="evenodd" clip-rule="evenodd" d="....very long path..." fill="black"/>
</svg>

gulp.task('build-icons', function() {
    return gulp.src(`src/svgs/*.svg`)
        .pipe(gulpRename((path) => {
            //rename svg, not important for the scope
        }))
        .pipe(gulpChange(function(content, done) {
            //here I want to "convert" the svg to a JS file
            //I'm open to ideas for this part, either use document.create, 
            //or whatever allows me to obtain a SVG that I can then import
            //and inject using JQuery
        }))
        .pipe(gulp.dest('dist/icons/'));
});

about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda