I need to add custom bootstrap template to asp.net core spa template. I\'ve created the temple using command:
dotnet new --install Microsoft.AspNetCore.SpaTe
Update:
How to enable less build is also well documented:
Example: A simple Webpack setup that builds LESS
This post, by Brian Mancini, relating to the React SPA template may help or apply similarly to the Angular SPA Template as well:
ASP.NET Core Bootstrap Customization
Copying a summary below:
Install LESS and less-loader
npm install --save less less-loader
Under ClientApp setup the following files and folders
less/site.less
less/bootstrap/bootstrap.less
less/bootstrap/variables.less
Configure the bootstrap and variables less files
/* less/bootsrap/bootstrap.less */
/* import bootstrap from source */
@import '../../../node_modules/bootstrap/less/bootstrap.less';
/* import custom overrides */
@import 'variables.less';
/* less/bootstrap/variables.less */
/* import the original file */
@import '../../../node_modules/bootstrap/less/variables.less';
/* Variables your overrides below
-------------------------------------------------- */
/* less/site.less */
@import './bootstrap/variables.less';
/* your overrides below */
Modify webpack.config.vendor.js
Remove configuration related to css file generation. Final vendor config will look like below:
See gist webpack.vendor.config.js
Modify webpack.config.js
to perform the less conversion
See gist webpack.config.js
Modify boot-client.ts
to include site and bootstrap less
import './less/site.less';
import './less/bootstrap/bootstrap.less';
Test your build by running
node node_modules/webpack/bin/webpack.js --config webpack.config.js
node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js
Modify _Layout.cshtml
to include bootstrap.css