-
Notifications
You must be signed in to change notification settings - Fork 519
style cannot load font awesome font file in Angular2SPA #335
Comments
Can you make sure you're on the latest version of
|
Oh wait, I see the issue. Internally, font-awesome refers to its own files with querystrings, e.g.,
These URLs don't match the regexes you have configured in The same thing means that the fix for #332 doesn't cover this case. I'll shortly update UPDATE: |
I will suggest using the CDN for the font awesome, that's what I am doing. Also, add this to _layout.cshtml. This is working for me, still i am facing other theme issues when adding those using 'require' <title>@viewdata["Title"] - AspnetSpa</title>
|
@SteveSandersonMS now with new aspnet-webpack and changing the loaders in webpack.config i don't see any exception. Still components don;t show proper theme, also i checked vender.css but the primeng css are not added to that. |
It would be really helpful if someone can guide how external components can be integrated. A sample is provided for primeng with webpack on (github https://github.com/primefaces/primeng-quickstart-webpack.) I am struggling to do the same with template provided by MS team from last 1 week. Thx again for helping with this. |
Although you technically can load 3rd-party vendor CSS scoped to individual Angular 2 components (i.e., by defining When you integrate with something like PrimeNG or font-awesome, it's much better to put them in your vendor bundle. This is consistent with how PrimeNG's official sample code works: they don't scope the styles to individual components; they load the CSS via a vendor bundle. Here's an example of a straightforward way of doing that from the latest Angular2Spa template: cff75c6 When copying this implementation into your project, please be sure to update the Also, an important caveat if you plan to use PrimeNG: not all of it is compatible with server-side rendering, because for some of their components, they depend on jQuery and jQuery UI (which don't run inside Node). So you should either disable server-side prerendering, or avoid the PrimeNG components that are incompatible (e.g., the date picker, which really uses jQuery UI), or at least ensure that you only attempt to render the incompatible components when the code is running on the client, not on the server. If this is a problem in your app, you might want to work with the PrimeNG people to remove the jQuery dependency so that their library can be compatible with angular-universal. |
Steve is spot on as always! As a side note @tanwarsatya I'd suggest using something like ng2bootstrap or Material design, which don't use any jQuery/etc, if server pre-rendering is important to you! They should work without any problems there. |
Hi I have just updated aspnet-webpack to 1.0.16, and assemble the changes in the PrimeNg sample https://github.com/aspnet/JavaScriptServices/commit/cff75c68933ebf6d2737a33f84dcb4076d1fd974 , and I continue to get the webpack error while parsing eot font files. ERROR in ./~/font-awesome/fonts/fontawesome-webfont.eot?v=4.6.3 Do I do something wrong? |
You need to setup all the needed webpack loaders : [] for all those scenarios (in this case
Take a look at Steves commit here (cff75c6) at things you'll need. |
I re-synchronized the entire project to the head on Sept 28, 2016 and it worked. Thank you very much. |
While trying to use one of PrimeNg's sample, in Angular2SPA template, which required to add font-awesome to the Component style's path to load font awesome's CSS file. The URL loader has trouble handling the font file called within one of font awesome's CSS, and showed the following error:
ERROR in ./~/font-awesome/fonts/fontawesome-webfont.eot?v=4.6.3
Module parse failed: C:\workspace10\Angular2Spa\node_modules\font-awesome\fonts\fontawesome-webfont.eot?v=4.6.3 Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type.
The sample code is tested in counter.component.ts, and is based on PrimeNg's official sample code.
http://www.primefaces.org/primeng/#/setup
the WebPack file is modified to use url-loader to handle .eot file, but did not work.
The text was updated successfully, but these errors were encountered: