File tree Expand file tree Collapse file tree
src/tools/BootstrapBlazor.CssBundler Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved.
2+ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+ // Website: https://www.blazor.zone or https://argozhang.github.io/
4+
5+ namespace BootstrapBlazor . CssBundler ;
6+
7+ static class ArgumentsHelper
8+ {
9+ public static void PrintHelp ( )
10+ {
11+ Console . ForegroundColor = ConsoleColor . Cyan ;
12+ Console . WriteLine ( "Usage: BootstrapBlazorCssBundler [options]" ) ;
13+ Console . WriteLine ( "Options:" ) ;
14+ Console . WriteLine ( " <bundler.json> ConfigFileFullPath D:\\ Argo\\ src\\ BootstrapBlazor\\ src\\ BootstrapBlazor\\ bundler.json" ) ;
15+ Console . WriteLine ( ) ;
16+ Console . ForegroundColor = ConsoleColor . Gray ;
17+ }
18+
19+ public static string ? ParseOptions ( string [ ] args )
20+ {
21+ return args . Length > 0 ? args [ 0 ] : "" ;
22+ }
23+ }
Original file line number Diff line number Diff line change 1+ <Project Sdk =" Microsoft.NET.Sdk" >
2+
3+ <PropertyGroup >
4+ <Version >1.0.0</Version >
5+ <OutputType >Exe</OutputType >
6+ <TargetFramework >net9.0</TargetFramework >
7+ <ImplicitUsings >enable</ImplicitUsings >
8+ <Nullable >enable</Nullable >
9+ </PropertyGroup >
10+
11+ <PropertyGroup >
12+ <TargetFrameworks >net9.0</TargetFrameworks >
13+ </PropertyGroup >
14+
15+ <PropertyGroup >
16+ <Title >BootstrapBlazor Css Bundler</Title >
17+ <PackageId >BootstrapBlazor.CssBundler</PackageId >
18+ <PackAsTool >true</PackAsTool >
19+ <ToolCommandName >bb-bundler</ToolCommandName >
20+ <Authors >Argo Zhang(Argo@live.ca)</Authors >
21+ <Copyright >Copyright 2025</Copyright >
22+ <Company >Longbow</Company >
23+ </PropertyGroup >
24+
25+ <ItemGroup >
26+ <SupportedPlatform Remove =" browser" />
27+ </ItemGroup >
28+
29+ </Project >
Original file line number Diff line number Diff line change 1+ // Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved.
2+ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+ // Website: https://www.blazor.zone or https://argozhang.github.io/
4+
5+ namespace BootstrapBlazor . CssBundler ;
6+
7+ internal class Bundler
8+ {
9+ public static void Run ( string [ ] args )
10+ {
11+ #if DEBUG
12+ if ( args . Length == 0 )
13+ {
14+ args = [
15+ "C:\\ Users\\ Argo\\ src\\ BootstrapBlazor\\ src\\ BootstrapBlazor\\ bundler.json"
16+ ] ;
17+ }
18+ #endif
19+
20+ var bundlerFile = ArgumentsHelper . ParseOptions ( args ) ;
21+
22+ if ( string . IsNullOrEmpty ( bundlerFile ) )
23+ {
24+ ArgumentsHelper . PrintHelp ( ) ;
25+ return ;
26+ }
27+
28+ BundlerCore ( bundlerFile ) ;
29+ }
30+
31+ static void BundlerCore ( string bundlerFile )
32+ {
33+ var option = BundlerOptions . LoadFromConfigFile ( bundlerFile ) ;
34+
35+ if ( string . IsNullOrEmpty ( option . OutputFileName ) )
36+ {
37+ return ;
38+ }
39+
40+ if ( option . InputFiles . Count == 0 )
41+ {
42+ return ;
43+ }
44+
45+ var rootFolder = Path . GetDirectoryName ( bundlerFile ) ;
46+ if ( string . IsNullOrEmpty ( rootFolder ) )
47+ {
48+ return ;
49+ }
50+
51+ using var writer = File . OpenWrite ( Path . Combine ( rootFolder , option . OutputFileName ) ) ;
52+ foreach ( var file in option . InputFiles )
53+ {
54+ var inputFile = Path . Combine ( rootFolder , file ) ;
55+ if ( ! File . Exists ( inputFile ) )
56+ {
57+ continue ;
58+ }
59+
60+ using var reader = File . OpenText ( inputFile ) ;
61+ reader . BaseStream . CopyTo ( writer ) ;
62+ reader . Close ( ) ;
63+ }
64+ writer . Close ( ) ;
65+
66+ Console . WriteLine ( $ "Bundler Completed .... { option . OutputFileName } ") ;
67+ }
68+ }
Original file line number Diff line number Diff line change 1+ // Licensed to the .NET Foundation under one or more agreements.
2+ // The .NET Foundation licenses this file to you under the Apache 2.0 License
3+ // See the LICENSE file in the project root for more information.
4+ // Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
5+
6+ using System . Text . Json ;
7+
8+ namespace BootstrapBlazor . CssBundler ;
9+
10+ sealed class BundlerOptions
11+ {
12+ public string ? OutputFileName { get ; set ; }
13+
14+ public List < string > InputFiles { get ; set ; } = [ ] ;
15+
16+ public static BundlerOptions LoadFromConfigFile ( string configFile )
17+ {
18+ var json = File . ReadAllText ( configFile ) ;
19+
20+ return JsonSerializer . Deserialize < BundlerOptions > ( json , JsonSerializerOptions . Web ) ?? new ( ) ;
21+ }
22+ }
Original file line number Diff line number Diff line change 1+ // Licensed to the .NET Foundation under one or more agreements.
2+ // The .NET Foundation licenses this file to you under the Apache 2.0 License
3+ // See the LICENSE file in the project root for more information.
4+ // Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
5+
6+ using BootstrapBlazor . CssBundler ;
7+
8+ Bundler . Run ( args ) ;
You can’t perform that action at this time.
0 commit comments