Closed stibay closed 7 years ago
We had some big updates the past few days! Think we need to add the postinstall script back that installs the vendor bundle.
Can you run the vendor pack, then regular webpack should work.
webpack --config webpack.config.vendor.js
Let us know!
I ran into this as well when I recently cloned to a new machine. The main repo has had this issue as well: https://github.com/aspnet/JavaScriptServices/issues/99
Although, I think this new section in the .csproj should address it:
<Target Name="RunWebpack" AfterTargets="ComputeFilesToPublish">
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
<Exec Command="npm install" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod" />
<Exec Command="node node_modules/webpack/bin/webpack.js --env.prod" />
<!-- Include the newly-built files in the publish output -->
<ItemGroup>
<DistFiles Include="wwwroot\dist\**; ClientApp\dist\**" />
<ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
<RelativePath>%(DistFiles.Identity)</RelativePath>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</ResolvedFileToPublish>
</ItemGroup>
</Target>
I'll try a fresh clone to confirm.
i also noticed this build issue this will fix it:
webpack --config webpack.config.vendor.js
after that 'dotnet run dev' should work
however the csproj change does not try to build the vendor.js at the moment how should that 'RunWebpack' target be executed, through 'dotnet run prod'?
Right now, the RunWebpack
target gets executed prior to publish. We could either add a script to package.json or have that target execute as part of the default build/compile. See also: https://github.com/JohannesHoppe/angularCore/commit/b5b759a55164c6972e467bf66dccdc76e26e74ec
@stibay Did you give that command a shot?
Yes, thank you. That fixed it.
However, we still need to fix this in the build though @stibay can you please reopen?
Fixes the issue. The only downside is that it'll build the vendor files twice when publishing. First one time dev-style and then rebuilds the files one time prod-style, which means the prod-style files will always be the ones being used.
The only other way is to hack inside the csproj-file to dynamically run the vendor building without the prod flag, and also exclude all the other things being run. Not sure if this is doable, I'm unfortunately some what of a noob when it comes to .NET but is seems to be much more complicated. Unless you have a huge amount of vendor files, this shouldn't be a huge issue since the build time penalty should be quite small.
After cloning and running yarn I am getting this error when running webpack: