Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Publishing Angular2SPA includes node_modules #429

Closed
MikeHook opened this issue Nov 14, 2016 · 5 comments
Closed

Publishing Angular2SPA includes node_modules #429

MikeHook opened this issue Nov 14, 2016 · 5 comments

Comments

@MikeHook
Copy link

AFAIK the node_modules should not be needed as they are precompiled into the vendor.js file.
I removed them from my project by taking the folder out of the publishOptions include list in project.json. However the site only works then if the asp-prerender tag is also removed from the home page markup.

Also tried adding the aspnet-prerendering module to the webpack.config.vendor.js list but then the compiled javascript didn't run.

@MrCrimp
Copy link

MrCrimp commented Nov 16, 2016

This is because the template you use is set up with server side rendering.
Unless I completely misunderstood how this works, node_modules is needed if you use server rendering (the asp-prerender tag) since this tag instructs the server to start a node.js process to do it's work before returning the resulting HTML to the client, where your client side javascript takes over. The node.js process needs node_modules to be present for this to work, it does'nt use your webpack bundles for it's internal work.

@boban100janovski
Copy link

As @MrCrimp said "node_modules" folder is needed for pre-rendering, just remove the "asp-prerender-module" tag from the MVC view and it will work (as you already know 😄)

@SteveSandersonMS
Copy link
Member

You are all correct - node_modules is needed if and only if you're doing server-side prerendering. Since that is on by default, that directory is also published by default.

@MikeHook
Copy link
Author

Thanks for clearing that up guys :)

@SteveSandersonMS
Copy link
Member

SteveSandersonMS commented Dec 7, 2016

Update: Deploying node_modules to production continues to cause trouble for people, so in the latest templates, we've eliminated the need to do that.

If you get the latest generator-aspnetspa-core and create a new project, you'll find its webpack config now builds a completely self-contained server-side prerendering bundle which never needs to reference node_modules at runtime. Therefore the default publishing config no longer includes node_modules at all.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants