Skip to content

Commit e4a3ac1

Browse files
committed
VueCliMiddleware extension added to run vue client app
1 parent 7b95d28 commit e4a3ac1

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

AspNetCoreVueStarter.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<ItemGroup>
1919
<PackageReference Include="Microsoft.AspNetCore.App" />
2020
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="2.1.1" />
21+
<PackageReference Include="VueCliMiddleware" Version="2.1.1" />
2122
</ItemGroup>
2223

2324
<ItemGroup>

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ There are two ways how to set up the project: one for people who want to create
5555

5656
* Clone this repository `git clone https://github.com/SoftwareAteliers/asp-net-core-vue-starter`
5757

58-
* **Remove all the contents** of the folder /ClientApp
58+
* **Remove all the contents** of the folder /ClientApp
5959
* Create a new Vue project by using Vue CLI: `vue create client-app` OR by using CLI graphical interface running `vue ui`
6060

6161
> Unfortunately Vue CLI does not allow us to set a project name by C# standards using Upper Camel Case (Pascal Case) naming convention, so let's initiate app inside of client-app folder and then move the content to ClientApp.
@@ -76,16 +76,10 @@ You have two choices when it comes to how you prefer to run the app. You can eit
7676

7777
### 1. Using the command line
7878

79-
> Normally we would run `dotnet run` command to run ASP.NET application and Microsoft ASP.NET Core JavaScriptServices middleware would start a new process for client side application, but middleware does not support Vue CLI 3 out-of-the-box right now, there's a [pull request](https://github.com/aspnet/JavaScriptServices/pull/1726) waiting to be merged.
80-
81-
For now:
82-
83-
* Run the Vue app in /asp-net-core-vue-starter/ClientApp folder with `npm run serve`
8479
* Run the .NET application using `dotnet run`
8580

8681
### 2. Using the built-in run command
8782

88-
* Run the Vue app in /asp-net-core-vue-starter/ClientApp folder with `npm run serve`
8983
* Run the application in VSCode or Visual Studio 2017 by hitting `F5`
9084

9185
## View your application running

Startup.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Microsoft.AspNetCore.Mvc;
44
using Microsoft.Extensions.Configuration;
55
using Microsoft.Extensions.DependencyInjection;
6+
using VueCliMiddleware;
67

78
namespace AspNetCoreVueStarter
89
{
@@ -57,7 +58,11 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
5758

5859
if (env.IsDevelopment())
5960
{
60-
spa.UseProxyToSpaDevelopmentServer("http://localhost:8080"); // your Vue app port
61+
// run npm process with client app
62+
spa.UseVueCli("serve", 8080); // your Vue app port
63+
// if you just prefer to proxy requests from client app, use proxy to SPA dev server instead:
64+
// app should be already running before starting a .NET client
65+
// spa.UseProxyToSpaDevelopmentServer("http://localhost:8080");
6166
}
6267
});
6368
}

0 commit comments

Comments
 (0)