-
Notifications
You must be signed in to change notification settings - Fork 0
/
instructions.txt
59 lines (45 loc) · 1.86 KB
/
instructions.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
If you're not yet using ASP.NET Core 2.0 (or don't have the Microsoft.AspNetCore.All package installed) then you need to install JavascriptServices.
This can be done through the following command: "dotnet add package Microsoft.AspNetCore.SpaServices".
Afterwards, open the Startup.cs file and add the following "using" statement at the top of the file:
"using Microsoft.AspNetCore.SpaServices.Webpack;"
Then move on to the Configure() method. Make sure that this method contains the following code, and add missing parts accordingly:
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
{
HotModuleReplacement = true,
ConfigFile="webpack.netcore.config.js",
HotModuleReplacementClientOptions = new Dictionary<string,string>{
{"reload", "true"}
}
});
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
routes.MapSpaFallbackRoute(
name: "spa-fallback",
defaults: new { controller = "Home", action = "Index" });
});
Then, in the ConfigureServices method, make sure that the application uses Mvc:
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
That's it for the Startup.cs file.
If you're using Typescript then it's necessary to instruct Visual Studio not to transpile Typescript. This can be done by opening up the .csproj file.
In this .csproj file you need to specify a TypeScriptToolsVersion and TypeScriptCompileBlocked like so:
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
</PropertyGroup>
That's it for the .csproj file.