DEV Community

Discussion on: Managing ASP.NET Core MVC front-end dependencies with npm and webpack (part 2)

Collapse
 
larswillemsens profile image
Lars Willemsens

Hey, thanks for your comment! You won't be able to use jQuery in a script section using this setup. You can use jQuery in a JavaScript file that will be picked up by webpack, however.
If you do need jQuery in an inline JavaScript section, then I'd recommend adding reference to a jQuery CDN as well.
Hope this helps your refactoring. Good luck!!

Collapse
 
martajohnsson profile image
Marta Johnsson

Thank You for Your answer.
I did find another solution. I can use expose-loader to make it work.
{
test: require.resolve("jquery"),
loader: "expose-loader",
options: {
exposes: ["$", "jQuery"],
},
},

Thread Thread
 
larswillemsens profile image
Lars Willemsens

Great! That looks like an ideal solution. Thanks for the addition!