DEV Community

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

Collapse
 
larswillemsens profile image
Lars Willemsens

Which bundles and pages do you have? If Vue is only imported for a single bundle then it won't be available on other pages that don't use this bundle.

Collapse
 
wokle profile image
AslamHamdi

Sorry. I'm new to node js. But here is what I did:

  1. I create an asp.net core MVC apps
  2. Then, I did exactly like the instruction in the post.
  3. I download vue and lodash using npm
  4. Then I import vue and lodash in entry.js and run 'npm run build'
  5. I create a page that share the same layout, _Layout.cshtml which share the same script site.entry.js

As for lodash, it worked fine. But for Vue, when I create a vue app in the other page it said Vue is not defined. But if I create a vue app in layout page and write the js code in site.js it worked.

Thread Thread
 
larswillemsens profile image
Lars Willemsens

So you have site.entry.js, which is loaded from two different pages, but only on one page it throws an error?

Thread Thread
 
wokle profile image
AslamHamdi

Yes. I loaded site.entry.js in _Layout.cshtml. I create new page which render in _Layout.cshtml . This new page throws an error.