Search code examples
reactjssharepointcreate-react-appsemantic-ui-react

Semantic UI React icons no longer bundled?


I'm using create-react-app and Semantic UI React to create a web part for SharePoint. (2016 on-prem. Started as 2013, so I wasn't able to use SPFx, so it's just regular old React.)

I created the solution as a Farm solution, so I could map the Layouts folder, and the CRA build output (.js and .css files) is getting deployed to the Layouts folder. I've also mapped the 16 hive folder on the dev server as a drive on my development machine, so part of my development process has been, after running npm run build, to copy the bundles directly over to the server so I can check on my changes/progress etc., without going through the usual SharePoint deployment process.

I have only ever copied the .js and .css files, and the icons used to work.

Now however, the icons are not showing up any more, and it looks like the code is trying to load icons.[hash].woff2, icons.[hash].woff and icons.[hash].ttf from the build/static/media folder in the CRA app.

Specifically, I'm seeing 404s for

https://servername/static/media/icons.[hash].woff2 etc.

Now, I would prefer to get the icons bundled in with the regular .css (and/or .js) files, so I don't have to worry about the media folder. However, I don't really have a problem with having to deploy the icon files in a media folder as well, but I would need the React build to know the correct place to look for them which would not be in

https://servername/static/media

it would be more like

https://servername/sites/my-site/_layouts/path/to/my/feature/media

So how can I either

  • get the icons bundled in the .css/.js files

or

  • indicate to CRA/Webpack the place where those files will actually end up, so the app is looking for them in the right place?

Solution

  • Bypassed the problem by switching from bundling the Semantic UI CSS to pulling it from the official CDN, which makes it pull the icons from a CDN somewhere, so I don't have to deal with them.