Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

139
Vistas
Font Awesome commenting out <i></i> tag after parsing

I'm working on a React application where I want conditional rendering of FontAwesome icons, but at the moment it's not changing when it should.

I inspected elements and found that FontAwesome is commenting out the React component and replacing it with the svg of the icon, so when I go back to change the FontAwesome icon in React, it has no effect. Below is an example of this

<!-- Expected -->
<i class="fa fa-pause"></i>
<!-- Actual -->
<svg class="svg-inline--fa fa-pause fa-w-14" aria-hidden="true" focusable="false" data-prefix="fa" data-icon="pause" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" data-fa-i2svg>...</svg>
<!-- <i class="fa fa-pause"></i> Font Awesome fontawesome.com -->

I know the cause of this probably has to do with a webpack change I recently made (moved the less loader into the webpack.rules.js instead of adding it in webpack.renderer.config.js and changed style-loader to MiniCssExtractPlugin.loader), but I'm not sure what exactly is causing it or how to fix it. I've included the fontawesome import and webpack below:

import '@fortawesome/fontawesome-free/js/all.js';
// webpack.rules.js
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

module.exports = [
  {
    test: /\.node$/,
    use: 'node-loader',
  },
  {
    test: /\.(m?js|node)$/,
    parser: {amd: false},
    use: {
      loader: '@marshallofsound/webpack-asset-relocator-loader',
      options: {
        outputAssetBase: 'native_modules',
      },
    },
  },
  {
    test: /\.tsx?$/,
    exclude: /(node_modules|\.webpack)/,
    use: {
      loader: 'ts-loader',
      options: {
        transpileOnly: true,
      },
    },
  },
  {
    test: /\.less$/,
    use: [MiniCssExtractPlugin.loader, {loader: 'css-loader'}, {loader: 'less-loader'}],
    exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/, /\.(config|variables|overrides)$/],
  },
]
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

This issue was solved once I changed the import to import '@fortawesome/fontawesome-free/css/all.css'; and made some adjustments to the config.

about 4 years ago · Juan Pablo Isaza Denunciar

0

The Font Awesome config has a property for this! https://fontawesome.com/v6/docs/apis/javascript/configuration#keeporiginalsource

keepOriginalSource (default: true): If replacing with inline SVG keep an HTML comment <-- --> with the original markup.

There are a few ways you can tweak the options.

Setting config from browser API:

window.FontAwesome.config.keepOriginalSource = false;

Setting config from svg core package:

import { config } from '@fortawesome/fontawesome-svg-core';
config.keepOriginalSource = false;

Setting config using script tag:

<script src="https://your-site-or-cdn.com/fontawesome/v6.1.1/js/all.js" data-keep-original-source ="false"></script>

Setting config object that will merge with default Font Awesome config:

FontAwesomeConfig = {
  keepOriginalSource: false
}

List of all available Font Awesome js configuration options and how to configure them: https://fontawesome.com/v6/docs/apis/javascript/configuration

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda