As I work on my current project using ASP.NET spa and Vue.js, I have been serving the dist folder from the Vue.js client app statically. This dist folder contains the compiled result of the client app's /src directory, where all .Vue and .ts files are located. Below is the snippet of code I am currently using in the startup.cs configuration:
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public static void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSpaStaticFiles(configuration => configuration.RootPath = "ClientApp/dist");
services.AddMvc();
// Add Singletons for the providers
services.AddSingleton<IActionDescriptorChangeProvider>(ControllerChangeProvider.Instance);
services.AddSingleton(ControllerChangeProvider.Instance);
}
public static void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseSpaStaticFiles();
app.UseAuthorization();
app.UseEndpoints(endpoints => endpoints.MapControllers());
app.UseSpa(spa => { });
}
}
Additionally, here is a snippet from the .csproj file:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>MyApplication</RootNamespace>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Text.Json" Version="4.7.1" />
<PackageReference Include="VueCliMiddleware" Version="3.0.0" />
</ItemGroup>
</Project>
While my TypeScript files in the /src directory, such as /router/index.ts, function as expected when served through a static server (using npm, for instance), running the ASP.NET server with IIS transpiles the .ts files into .js files within the /src folder. Although this transpilation does not affect functionality, it results in unnecessary code. Upon debugging the application from the main method, I observed that the transpilation occurs prior to the main method execution, indicating a configuration issue. Hence, my inquiry is: Is it possible to disable the transpilation of .ts files in ASP.NET?
I appreciate any feedback and am willing to provide further details as required. :)