From 057188329493ebf90a13863b6cc9d40c1045d9fa Mon Sep 17 00:00:00 2001 From: Ilkay Ilknur Date: Wed, 16 Dec 2020 14:14:06 +0300 Subject: [PATCH] bundling and minification section added. --- docs/en/UI/Blazor/Global-Scripts-Styles.md | 47 +++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/docs/en/UI/Blazor/Global-Scripts-Styles.md b/docs/en/UI/Blazor/Global-Scripts-Styles.md index a9a69c76d0..68628d200a 100644 --- a/docs/en/UI/Blazor/Global-Scripts-Styles.md +++ b/docs/en/UI/Blazor/Global-Scripts-Styles.md @@ -35,4 +35,49 @@ namespace MyProject.Blazor > There is a BundleContributor class implementing `IBundleContributor` interface coming by default with the startup templates. So, most of the time, you don't need to add it manually. -> Bundle command adds style and script references individually. Bundling and minification support will be added to incoming releases. \ No newline at end of file +## Bundling And Minification +`abp bundle` command offers bundling and minification support for client-side resources(JavaScript and CSS files). `abp bundle` command reads the `appsettings.json` file inside the Blazor project and bundles the resources according to the configuration. You can find the bundle configurations inside `AbpCli.Bundle` element. + +Here are the options that you can control inside the `appsettings.json` file. + +`Mode`: Bundling and minification mode. Possible values are +* `BundleAndMinify`: Bundle all the files into a single file and minify the content. +* `Bundle`: Bundle all files into a single file, but not minify. +* `None`: Add files individually, do not bundle. + +`Name`: Bundle file name. Default value is `global`. + +`Parameters`: You can define additional key/value pair parameters inside this section. `abp bundle` command automatically sends these parameters to the bundle contributors, and you can check these parameters inside the bundle contributor, take some actions according to these values. + +Let's say that you want to exclude some resources from the bundle and control this action using the bundle parameters. You can add a parameter to the bundle section like below. + +```json +"AbpCli": { + "Bundle": { + "Mode": "BundleAndMinify", /* Options: None, Bundle, BundleAndMinify */ + "Name": "global", + "Parameters": { + "ExcludeThemeFromBundle":"true" + } + } + } +``` + +You can check this parameter and take action like below. + +```csharp +public class MyProjectNameBundleContributor : IBundleContributor +{ + public void AddScripts(BundleContext context) + { + } + + public void AddStyles(BundleContext context) + { + var excludeThemeFromBundle = bool.Parse(context.Parameters.GetValueOrDefault("ExcludeThemeFromBundle")); + context.Add("mytheme.css", excludeFromBundle: excludeThemeFromBundle); + context.Add("main.css"); + } +} +``` +