<TargetName="PublishRunWebpack"AfterTargets="ComputeFilesToPublish"> <!-- As part of publishing, ensure the JS resources are freshly built in production mode --> <ExecCommand="npm install" /> <ExecCommand="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod" /> <ExecCommand="attrib wwwroot/dist/* -R /S" /> <ExecCommand="node node_modules/webpack/bin/webpack.js --env.prod" />
<!-- Include the newly-built files in the publish output --> <ItemGroup> <DistFilesInclude="wwwroot\dist\**" /> <ResolvedFileToPublishInclude="@(DistFiles->'%(FullPath)')"Exclude="@(ResolvedFileToPublish)"> <RelativePath>%(DistFiles.Identity)</RelativePath> <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> </ResolvedFileToPublish> </ItemGroup> </Target>