I'm trying to use Semantic UI with Angular 2 over Asp.Net Core. I've started with the aspnetcore-spa
project template from the JavaScript services official Yeoman templates which already has Asp.Net MVC Core, Webpack, Angular 2 and Bootstrap configured.
Then, I tried following the steps described on this GitHub to install Semantic UI.
The steps I did:
- Installed Semantic UI using NPM
npm install semantic-ui --save
- During the setup, I installed all the features and selected the install folder as
wwwroot/lib/semantic/
- During the setup, I installed all the features and selected the install folder as
- Went to the
wwwroot/lib/semantic
folder and rangulp build
That's where I started to be really unsure, in the template structure there's no vendor.ts
, so I was not really sure where to put the import for the Semantic css and js.
The only thing I could find was the webpack.config.vendor.js
that contained some entries for Bootstrap, so I modified the vendor
property and added the import for the semantic js and css.
Here's how I modified it:
entry: {
vendor: [
'@angular/common',
'@angular/compiler',
'@angular/core',
'@angular/http',
'@angular/platform-browser',
'@angular/platform-browser-dynamic',
'@angular/router',
'@angular/platform-server',
'angular2-universal',
'angular2-universal-polyfills',
'es6-shim',
'es6-promise',
'event-source-polyfill',
'jquery',
'zone.js',
'wwwroot/lib/semantic/dist/semantic.min.js',
'wwwroot/lib/semantic/dist/semantic.min.css',
'ng-semantic'
]
}
I removed the references to bootstrap and added semantic.min.js
, semantic.min.css
, and ng-semantic
.
Finally, I installed Ng-Semantic
using NPM and added import { NgSemanticModule } from 'ng-semantic'
into app.module.ts
.
Now, when I try to run the application, I get the following error:
System.Exception: Call to Node module failed with error: Prerendering failed because of error: ReferenceError: jQuery is not defined
I get that this error is caused by the system trying to pre-render some code that rely on jQuery which is a big no-no and it's probably the semantic-ui.js. But I have absolutely no idea how that could be fixed.
For reference and easier troubleshooting, I've pushed the current status of the code to GitHub, it's available at this address.
Thanks in advance!