I’m currently working on a .NET Core single page application using the React Template for ASP.NET Core SPA Yeoman Generator, which worked great so far.
However, after getting a fresh checkout, I started experiencing the error Cannot find module './wwwroot/dist/vendor-manifest.json'
when starting up on top of IIS Express.
Turns out that this is because, by default, the wwwroot/dist
directory is excluded from version control while the build process depends on the vendor-manifest.json
file therein.
However, the dist directory does not get regenerated on build for some reason.
Perhaps the prepublish step node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod
is not always executed, even though the main.js
and main.js.map
files are updated by build/debug?
The dist directory does get regenerated by running either webpack --config webpack.config.vendor.js
or dotnet publish
before debugging.
I just copied the prepublish step as a new precompile step in project.json
to prevent further head scratching:
Additionally, the project.json
file is configured to output the node_modules
directory by default.
This is not required so you can just remove the "node_modules",
line to prevent unnecessary copying of a large amount of files (unless, perhaps, if you refer to something in there that does not get bundled by webpack).
References: