Struggling to incorporate webpack into .NET 6 razor pages. The existing documentation online only adds to my confusion.
Here is a snippet from my file1.ts:
export function CCC(): string {
return "AAAAAA";
}
And here is another snippet from my file.ts:
import { CCC } from "./file1"
function AAA(): string {
return CCC();
}
This code block is from my Index.cshtml:
@page
@model IndexModel
@{
ViewData["Title"] = "Home page";
}
<script>
const str = AAA()
alert(str);
</script>
Below is the layout.cshtml content:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - TypeScriptLab5</title>
<link rel="stylesheet" href="~/TypeScriptLab5.styles.css" asp-append-version="true" />
<script src="~/ts/file1.js"></script>
<script src="~/ts/file.js"></script>
</head>
<body>
@RenderBody()
<script src="~/lib/jquery/dist/jquery.min.js"></script>
@await RenderSectionAsync("Scripts", required: false)
</body>
</html>
Lastly, this excerpt pertains to my program.cs file:
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorPages();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapRazorPages();
app.Run();
Hopefully, this detailed explanation provides context to my issue.