I'm trying to use https://github.com/ligershark/WebOptimizer as suggested by microsoft in order to bundle and minimise my js files, so following the instructions, I have the following in my startup.cs:
app.UseWebOptimizer();
app.UseStaticFiles();
and in my service configuration (startup.cs):
services.AddWebOptimizer(pipeline =>
{
pipeline.AddJavaScriptBundle("/js/site.js", // I have tried using MinifyJsFiles (without the use content root) instead of AddJavaScriptBundle
"/lib/jquery-ui-1.13.1.custom/jquery-ui.js",
"/js/auto-complete.js")
.UseContentRoot();
pipeline.MinifyJsFiles(); // I have tried with and without this line
});
and in my _layout:
<script src="~/js/site.js"></script>
But whenever I browse to the page, I'm just getting a 404 error in the network tab when it tries to load the site.js
Is there something I have missed? All the files are in their correct places in the wwwroot folder of the site
Verify these:
Your files should be somewhere inside the wwwroot directory (if using default configuration)
Your files should use the "Build Action = Content" (there should be nothing in csproj).
When you write:
A file at
wwwroot/main.css
will be available at url/main.css
.And when you write:
It will require a file to be at location
wwwroot/site.css
.