|
2 | 2 |
|
3 | 3 | [](https://www.nuget.org/packages/VueCliMiddleware/) |
4 | 4 |
|
5 | | -This is a stand-alone module to add VueCli support to AspNet Core 2.2.0. |
| 5 | +This is a stand-alone module to add Vue Cli and Quasar Cli support to AspNet Core. |
6 | 6 |
|
7 | | -## Usage Example |
| 7 | + |
| 8 | +## ASP.NET 3.0 Preview Endpoint Routing (experimental) |
| 9 | +First, be sure to switch Vue Cli or Quasar Cli to output distribution files to wwwroot directly (not dist). |
| 10 | + |
| 11 | +* Quasar CLI: regex: "Compiled successfully" |
| 12 | +* Vue CLI: regex: default or "running at" |
| 13 | + |
| 14 | +See [Migrating Asp.Net 2.2 to 3.0 Endpoint Routing](https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-2.2&tabs=visual-studio#update-routing-startup-code) |
| 15 | +```csharp |
| 16 | +// To use with EndpointRouting |
| 17 | +
|
| 18 | + app.UseEndpoints(endpoints => |
| 19 | + { |
| 20 | + endpoints.MapControllers(); |
| 21 | + |
| 22 | + // initialize vue cli middleware |
| 23 | +#if DEBUG |
| 24 | + if (System.Diagnostics.Debugger.IsAttached) |
| 25 | + endpoints.MapToVueCliProxy("{*path}", new SpaOptions { SourcePath = "ClientApp" }, "dev", regex: "Compiled successfully"); |
| 26 | + else |
| 27 | +#endif |
| 28 | + // note: output of vue cli or quasar cli should be wwwroot |
| 29 | + endpoints.MapFallbackToFile("index.html"); |
| 30 | + }); |
| 31 | +``` |
| 32 | + |
| 33 | + |
| 34 | +## ASP.NET 2.2 Usage Example |
8 | 35 | ```csharp |
9 | 36 | using VueCliMiddleware; |
10 | 37 |
|
@@ -57,46 +84,46 @@ This is a stand-alone module to add VueCli support to AspNet Core 2.2.0. |
57 | 84 | You may also need to add the following tasks to your csproj file. This are similar to what are found in the default ASPNETSPA templates. |
58 | 85 |
|
59 | 86 | ```project.csproj |
60 | | - <PropertyGroup> |
61 | | - <!-- Typescript/Javascript Client Configuration --> |
62 | | - <SpaRoot>ClientApp\</SpaRoot> |
63 | | - <DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes> |
| 87 | + <PropertyGroup> |
| 88 | + <!-- Typescript/Javascript Client Configuration --> |
| 89 | + <SpaRoot>ClientApp\</SpaRoot> |
| 90 | + <DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes> |
64 | 91 | </PropertyGroup> |
65 | | - <Target Name="DebugEnsureNodeEnv" BeforeTargets="Build"> |
66 | | - <!-- Build Target: Ensure Node.js is installed --> |
67 | | - <Exec Command="node --version" ContinueOnError="true"> |
68 | | - <Output TaskParameter="ExitCode" PropertyName="ErrorCode" /> |
69 | | - </Exec> |
70 | | - <Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." /> |
71 | | - </Target> |
72 | | - |
73 | | - <Target Name="DebugEnsureNpm" AfterTargets="DebugEnsureNodeEnv"> |
74 | | - <!-- Build Target: Ensure Node.js is installed --> |
75 | | - <Exec Command="npm --version" ContinueOnError="true"> |
76 | | - <Output TaskParameter="ExitCode" PropertyName="ErrorCode" /> |
77 | | - </Exec> |
78 | | - </Target> |
79 | | - |
80 | | - <Target Name="EnsureNodeModulesInstalled" BeforeTargets="Build" Inputs="package.json" Outputs="packages-lock.json"> |
81 | | - <!-- Build Target: Restore NPM packages using npm --> |
82 | | - <Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." /> |
83 | | - |
84 | | - <Exec WorkingDirectory="$(SpaRoot)" Command="npm install" /> |
85 | | - </Target> |
86 | | - |
87 | | - <Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish"> |
88 | | - <!-- Build Target: Run webpack dist build --> |
89 | | - <Message Importance="high" Text="Running npm build..." /> |
90 | | - <Exec WorkingDirectory="$(SpaRoot)" Command="npm run build" /> |
91 | | - |
92 | | - <!-- Include the newly-built files in the publish output --> |
93 | | - <ItemGroup> |
94 | | - <DistFiles Include="$(SpaRoot)dist\**" /> |
95 | | - <ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)"> |
96 | | - <RelativePath>%(DistFiles.Identity)</RelativePath> |
97 | | - <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |
98 | | - </ResolvedFileToPublish> |
99 | | - </ItemGroup> |
| 92 | + <Target Name="DebugEnsureNodeEnv" BeforeTargets="Build"> |
| 93 | + <!-- Build Target: Ensure Node.js is installed --> |
| 94 | + <Exec Command="node --version" ContinueOnError="true"> |
| 95 | + <Output TaskParameter="ExitCode" PropertyName="ErrorCode" /> |
| 96 | + </Exec> |
| 97 | + <Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." /> |
| 98 | + </Target> |
| 99 | + |
| 100 | + <Target Name="DebugEnsureNpm" AfterTargets="DebugEnsureNodeEnv"> |
| 101 | + <!-- Build Target: Ensure Node.js is installed --> |
| 102 | + <Exec Command="npm --version" ContinueOnError="true"> |
| 103 | + <Output TaskParameter="ExitCode" PropertyName="ErrorCode" /> |
| 104 | + </Exec> |
| 105 | + </Target> |
| 106 | + |
| 107 | + <Target Name="EnsureNodeModulesInstalled" BeforeTargets="Build" Inputs="package.json" Outputs="packages-lock.json"> |
| 108 | + <!-- Build Target: Restore NPM packages using npm --> |
| 109 | + <Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." /> |
| 110 | + |
| 111 | + <Exec WorkingDirectory="$(SpaRoot)" Command="npm install" /> |
| 112 | + </Target> |
| 113 | + |
| 114 | + <Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish"> |
| 115 | + <!-- Build Target: Run webpack dist build --> |
| 116 | + <Message Importance="high" Text="Running npm build..." /> |
| 117 | + <Exec WorkingDirectory="$(SpaRoot)" Command="npm run build" /> |
| 118 | + |
| 119 | + <!-- Include the newly-built files in the publish output --> |
| 120 | + <ItemGroup> |
| 121 | + <DistFiles Include="$(SpaRoot)dist\**" /> |
| 122 | + <ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)"> |
| 123 | + <RelativePath>%(DistFiles.Identity)</RelativePath> |
| 124 | + <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |
| 125 | + </ResolvedFileToPublish> |
| 126 | + </ItemGroup> |
100 | 127 | </Target> |
101 | 128 |
|
102 | 129 | ``` |
|
0 commit comments