I'm building an Angular2 app using the SPA templates and JavaScriptServices provided by Microsoft (https://blogs.msdn.microsoft.com/webdev/2017/02/14/building-single-page-applications-on-asp-net-core-with-javascriptservices/).
I'd like to use Angular Material as opposed to Bootstrap for styling/themeing, however I'm unable to get it to work.
Following the setup guide (https://material.angular.io/guide/getting-started) is straightforward enough, however when it comes to including the theme assets (@angular/material/prebuilt-themes/...) from the npm package in the wwwroot dist output to make them available to the app I'm at a complete loss.
I assume it's simply a case of modifying the WebPack configuration, however after an hour or two of tinkering and google searches I'm no closer to understanding what to do.
Can anybody point me in the right direction?
NB. Please don't suggest copying the files I need to the wwwroot or linking to a CDN etc.
I think I've possibly found a more complete/comprehensive way to achieve this...
node_modules
directorynpm install --save @angular/material @angular/cdk
in command promptnpm install --save @angular/animations
in command prompt@angular
and rxjs
packages to the latest/compatible versions in package.json
. This is a headache. I have no idea which are the right versions and which are wrong!npm install
in command promptUpdate webpack.config.vendor.js
, adding the following two values
const nonTreeShakableModules = [
...
'@angular/material',
'@angular/material/prebuilt-themes/deeppurple-amber.css'
];
Run webpack --config webpack.config.vendor.js
in command prompt
I've checked in a vaguely working version to GitHub - it can be found at https://github.com/alterius/AngularMaterial2DotNetCoreSPA
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With