Clink50
Looking for a best practice for compiling/bundling/minifying js and scss in a .NET 6 MVC application
We have integrated bundleconfig.json and compilerconfig.json for compiling our scss to css, however, we will be using some javascript with bootstrap and jquery to do some DOM manipulation here and there on different pages and I would like to have the JS compiled, bundled and minified. I wanted to look into maybe using webpack, but I wasn't sure what's recommended in this situation.
Right now we have a few pages, and some custom javascript on each page to show a modal, send an ajax request when a button is clicked in the modal, etc. We are either writing the JS directly in an
@section Scripts { ... }
or creating a JS file and including it on the View within the @section Scripts { ... }
. The main thing is that we don't have any JS linting / error checking, so that's where I was thinking we could have webpack come in.
Does anyone have any resources or repos that do something along the lines of what I'm trying to do? Is it even recommended to do this or just keep going with the bundleconfig.json and not worry about compiling?
Thanks!2 replies
❔ Need help understanding Model Binding better
I'm trying to re-familiarize myself with .NET Core MVC after using Web Forms for about 6 years. I'm working on a CMS, and when you go to a page, you retrieve all the content for that page from the CMS, map it to a view model, and then display all that information on the page. The data could be a title and description for example. But what if I also need a form on that same page? Now my view model is title, description, and now it has the Name and Age for form values and when you click the submit button, it will redirect you to a page. If the name is not filled in, it will show the error message. This is very simple, and I understand that I could use Html.HiddenFor for the title and description but what if there is a lot of properties in the view model, say 20 properties. Do I have to have 20 hidden elements to pass the view model in the form submission when all I need is the name and age?
18 replies