Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

281
Views
Webpack 5 usa html-loader para cargar svgs

Recientemente actualicé a Webpack 5 y mi cargador html ya no carga archivos svg ni los inserta.

Aquí está mi regla svg en webpack

 { test: /\.svg$/, use: [ { loader: 'html-loader', options: { minimize: true, }, }, ], },

No importa cómo intente importarlo, parece que solo crea un archivo y no me da una cadena de HTML.

 import mySvg from "../path/to/my.svg" let mySvg = require("../path/to/my.svg").default; // output = "/build/path/my.svg" // output I want = "<svg>...."

Solía no darme varios archivos de compilación, sino que los alineaba en mi JS.

La ayuda sería apreciada.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

svg-inline-loader puede lograr lo mismo (confirmado para funcionar).

He enumerado otras opciones para cargar archivos SVG en https://survivejs.com/webpack/loading/images/#loading-svgs .

about 4 years ago · Juan Pablo Isaza Report

0

Uso el complemento posthtml y posthtml-inline-svg .

 const postHtml = require('posthtml'); const postHtmlInlineSvg = require('posthtml-inline-svg'); { test: /\.html$/, use: { loader: 'html-loader', options: { esModule: false, preprocessor: async (content, loaderContext) => { try { return await postHtml(postHtmlInlineSvg({ cwd: loaderContext.context, tag: 'icon', attr: 'src' }),).process(content)).html; } catch (error) { loaderContext.emitError(error); return content; } }, }, }, },
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!