Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: react-ui-components FontAwesomeIcon externally nearly unusable #3378

Closed
Tracked by #3366
mhsdesign opened this issue Feb 16, 2023 · 1 comment
Closed
Tracked by #3366

Comments

@mhsdesign
Copy link
Member

see what the media-ui is doing:

https://github.com/Flowpack/media-ui/blob/38ca2f09d9c345c64bbf77d3655ea9bb3eb56da1/patches/@neos-project+react-ui-components+5.3.13.patch

https://github.com/Flowpack/media-ui/blob/38ca2f09d9c345c64bbf77d3655ea9bb3eb56da1/Resources/Private/JavaScript/media-module/src/lib/FontAwesome.ts#L59-L63

there are two problems the media ui tries to solve with their hack:

  1. the styles in import '@fortawesome/fontawesome-svg-core/styles.css'; are originally prefixed with svg-inline--fa but in the big ui bundle we go extra legths to ensure encapsulation (do we need to?) by prefixing it in the build with neos-

    neos-ui/esbuild.js

    Lines 63 to 73 in 5e7ae4a

    // prefix Fontawesome with "neos-" to prevent clashes with customer Fontawesome
    onLoad({filter: /@fortawesome\/fontawesome-svg-core\/styles\.css$/}, async ({path}) => {
    const contents = (await require('fs/promises').readFile(path)).toString();
    const replacedStyle = contents.replace(/svg-inline--fa/g, 'neos-svg-inline--fa');
    return {
    contents: replacedStyle,
    loader: 'css'
    }
    })
    and we also modify font awesome to use our neos prefix. But when using the react-ui-components externally you dont want to have that extra css replace step in place.
  2. using the has a sideeffect and all fontawesome icons are bundled into your package (what you might not like if you at least a little care about bundle size ^^)
@mhsdesign
Copy link
Member Author

fixed by #3366

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

No branches or pull requests

1 participant