Skip to content

Commit ba03ad7

Browse files
committed
Bundling of application scripts and styles.
1 parent 8336d1a commit ba03ad7

File tree

9 files changed

+37
-21
lines changed

9 files changed

+37
-21
lines changed

Templates/All-In-One-Template/MySpaProject/MySpaProject.WebSpaAngular/App/Main/views/layout/layout.cshtml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
<!DOCTYPE html>
1+
@using System.Web.Optimization
2+
<!DOCTYPE html>
23
<html lang="en">
34
<head>
45

5-
<!-- Standard meta tags -->
6+
<!-- Common meta tags -->
67
<meta charset="utf-8">
78
<meta http-equiv="X-UA-Compatible" content="IE=edge">
89
<meta name="viewport" content="width=device-width, initial-scale=1">
@@ -26,7 +27,7 @@
2627

2728
<!-- Country flags -->
2829
<link href="~/Content/flags/famfamfam-flags.css" rel="stylesheet" />
29-
30+
3031
<!-- Font awecome -->
3132
<link href="~/Content/font-awesome.min.css" rel="stylesheet" />
3233

@@ -45,7 +46,8 @@
4546
<script src="@Url.Content("~/Scripts/others/respond.min.js")"></script>
4647
<![endif]-->
4748

48-
<link href="~/App/Main/styles/main.css" rel="stylesheet" />
49+
<!-- Application styles -->
50+
@Styles.Render("~/Bundles/App/Main/css")
4951

5052
<!-- Windows Phone 8 and Internet Explorer 10 FIX -->
5153
<script src="~/Abp/Framework/scripts/utils/ie10fix.js"></script>
@@ -86,13 +88,9 @@
8688
<script src="~/api/AbpServiceProxies/GetAll?type=angular"></script>
8789
<script src="~/AbpLocalization/GetScripts" type="text/javascript"></script>
8890
<script src="~/AbpNavigation/GetScripts" type="text/javascript"></script>
89-
91+
9092
<!-- Application scripts -->
91-
<script src="~/App/Main/app.js"></script>
92-
<script src="~/App/Main/views/layout/layout.js"></script>
93-
<script src="~/App/Main/views/layout/header.js"></script>
94-
<script src="~/App/Main/views/home/home.js"></script>
95-
<script src="~/App/Main/views/about/about.js"></script>
93+
@Scripts.Render("~/Bundles/App/Main/js")
9694

9795
</head>
9896

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Web.Optimization;
2+
3+
namespace MySpaProject.WebSpaAngular
4+
{
5+
public static class BundleConfig
6+
{
7+
public static void RegisterBundles(BundleCollection bundles)
8+
{
9+
bundles.IgnoreList.Clear();
10+
11+
//~/App/Main/css //TODO: Does it includes both .css and .min.css?
12+
bundles.Add(new StyleBundle("~/Bundles/App/Main/css").IncludeDirectory("~/App/Main", "*.css", true));
13+
14+
//~/App/Main/js //TODO: Does it includes both .js and .min.js?
15+
bundles.Add(new ScriptBundle("~/Bundles/App/Main/js").IncludeDirectory("~/App/Main", "*.js", true));
16+
}
17+
}
18+
}

Templates/All-In-One-Template/MySpaProject/MySpaProject.WebSpaAngular/App_Start/MySpaProjectWebModule.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Reflection;
22
using System.Web;
33
using System.Web.Mvc;
4+
using System.Web.Optimization;
45
using System.Web.Routing;
56
using Abp.Localization;
67
using Abp.Localization.Sources.Xml;
@@ -13,9 +14,11 @@ public class MySpaProjectWebModule : AbpModule
1314
{
1415
public override void PreInitialize()
1516
{
17+
//Add/remove languages for your application
1618
Configuration.Localization.Languages.Add(new LanguageInfo("en", "English", "famfamfam-flag-england", true));
1719
Configuration.Localization.Languages.Add(new LanguageInfo("tr", "Türkçe", "famfamfam-flag-tr"));
1820

21+
//Configure navigation/menu
1922
Configuration.Navigation.Providers.Add<MySpaProjectNavigationProvider>();
2023
}
2124

@@ -32,6 +35,7 @@ public override void Initialize()
3235

3336
AreaRegistration.RegisterAllAreas();
3437
RouteConfig.RegisterRoutes(RouteTable.Routes);
38+
BundleConfig.RegisterBundles(BundleTable.Bundles);
3539
}
3640
}
3741
}

Templates/All-In-One-Template/MySpaProject/MySpaProject.WebSpaAngular/App_Start/RouteConfig.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Web;
5-
using System.Web.Http;
1+
using System.Web.Http;
62
using System.Web.Mvc;
73
using System.Web.Routing;
84

95
namespace MySpaProject.WebSpaAngular
106
{
11-
public class RouteConfig
7+
public static class RouteConfig
128
{
139
public static void RegisterRoutes(RouteCollection routes)
1410
{

Templates/All-In-One-Template/MySpaProject/MySpaProject.WebSpaAngular/MySpaProject.WebSpaAngular.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@
182182
</Content>
183183
<Content Include="App\Main\app.js" />
184184
<Content Include="App\Main\images\abp-logo.png" />
185-
<Content Include="App\Main\styles\main.css">
185+
<Content Include="App\Main\main.css">
186186
<DependentUpon>main.less</DependentUpon>
187187
</Content>
188-
<Content Include="App\Main\styles\main.min.css">
188+
<Content Include="App\Main\main.min.css">
189189
<DependentUpon>main.css</DependentUpon>
190190
</Content>
191191
<Content Include="App\Main\views\layout\header.js" />
@@ -277,7 +277,7 @@
277277
<Content Include="Scripts\angular-ui\ui-utils.min.js" />
278278
<Content Include="Content\toastr.scss" />
279279
<Content Include="Content\toastr.less" />
280-
<Content Include="App\Main\styles\main.less" />
280+
<Content Include="App\Main\main.less" />
281281
<Content Include="App\Main\views\layout\layout.cshtml" />
282282
<Content Include="App\Main\views\home\home.cshtml" />
283283
<Content Include="App\Main\views\about\about.cshtml" />
@@ -1065,6 +1065,7 @@
10651065
<Content Include="Views\_ViewStart.cshtml" />
10661066
</ItemGroup>
10671067
<ItemGroup>
1068+
<Compile Include="App_Start\BundleConfig.cs" />
10681069
<Compile Include="App_Start\MySpaProjectNavigationProvider.cs" />
10691070
<Compile Include="App_Start\MySpaProjectWebModule.cs" />
10701071
<Compile Include="App_Start\RouteConfig.cs" />
@@ -1092,7 +1093,6 @@
10921093
<ItemGroup>
10931094
<Folder Include="App\Common\images\" />
10941095
<Folder Include="App\Common\scripts\" />
1095-
<Folder Include="App\Main\scripts\" />
10961096
<Folder Include="App_Data\" />
10971097
<Folder Include="Models\" />
10981098
</ItemGroup>

Templates/All-In-One-Template/MySpaProject/MySpaProject.WebSpaAngular/Views/Shared/_Layout.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44

5-
<!-- Standard meta tags -->
5+
<!-- Common meta tags -->
66
<meta charset="utf-8">
77
<meta http-equiv="X-UA-Compatible" content="IE=edge">
88
<meta name="viewport" content="width=device-width, initial-scale=1">

0 commit comments

Comments
 (0)