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

Commit a2bde75

Browse files
Make templates auto-run webpack on Debug build if wwwroot/dist is not already present
1 parent c592282 commit a2bde75

File tree

6 files changed

+54
-6
lines changed

6 files changed

+54
-6
lines changed

templates/AngularSpa/AngularSpa.csproj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,15 @@
2121
<Content Remove="ClientApp\**" />
2222
</ItemGroup>
2323

24-
<Target Name="RunWebpack" AfterTargets="ComputeFilesToPublish">
24+
<Target Name="DebugRunWebpack" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('wwwroot\dist') ">
25+
<!-- In development, the dist files won't exist on the first run or when cloning to
26+
a different machine, so rebuild them if not already present. -->
27+
<Message Importance="high" Text="Performing first-run Webpack build..." />
28+
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js" />
29+
<Exec Command="node node_modules/webpack/bin/webpack.js" />
30+
</Target>
31+
32+
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
2533
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
2634
<Exec Command="npm install" />
2735
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod" />

templates/AureliaSpa/AureliaSpa.csproj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@
1616
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0-*" />
1717
</ItemGroup>
1818

19-
<Target Name="RunWebpack" AfterTargets="ComputeFilesToPublish">
19+
<Target Name="DebugRunWebpack" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('wwwroot\dist') ">
20+
<!-- In development, the dist files won't exist on the first run or when cloning to
21+
a different machine, so rebuild them if not already present. -->
22+
<Message Importance="high" Text="Performing first-run Webpack build..." />
23+
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js" />
24+
<Exec Command="node node_modules/webpack/bin/webpack.js" />
25+
</Target>
26+
27+
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
2028
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
2129
<Exec Command="npm install" />
2230
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod" />

templates/KnockoutSpa/KnockoutSpa.csproj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@
1616
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0-*" />
1717
</ItemGroup>
1818

19-
<Target Name="RunWebpack" AfterTargets="ComputeFilesToPublish">
19+
<Target Name="DebugRunWebpack" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('wwwroot\dist') ">
20+
<!-- In development, the dist files won't exist on the first run or when cloning to
21+
a different machine, so rebuild them if not already present. -->
22+
<Message Importance="high" Text="Performing first-run Webpack build..." />
23+
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js" />
24+
<Exec Command="node node_modules/webpack/bin/webpack.js" />
25+
</Target>
26+
27+
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
2028
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
2129
<Exec Command="npm install" />
2230
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod" />

templates/ReactReduxSpa/ReactReduxSpa.csproj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,15 @@
2121
<Content Remove="ClientApp\**" />
2222
</ItemGroup>
2323

24-
<Target Name="RunWebpack" AfterTargets="ComputeFilesToPublish">
24+
<Target Name="DebugRunWebpack" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('wwwroot\dist') ">
25+
<!-- In development, the dist files won't exist on the first run or when cloning to
26+
a different machine, so rebuild them if not already present. -->
27+
<Message Importance="high" Text="Performing first-run Webpack build..." />
28+
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js" />
29+
<Exec Command="node node_modules/webpack/bin/webpack.js" />
30+
</Target>
31+
32+
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
2533
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
2634
<Exec Command="npm install" />
2735
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod" />

templates/ReactSpa/ReactSpa.csproj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@
1616
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0-*" />
1717
</ItemGroup>
1818

19-
<Target Name="RunWebpack" AfterTargets="ComputeFilesToPublish">
19+
<Target Name="DebugRunWebpack" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('wwwroot\dist') ">
20+
<!-- In development, the dist files won't exist on the first run or when cloning to
21+
a different machine, so rebuild them if not already present. -->
22+
<Message Importance="high" Text="Performing first-run Webpack build..." />
23+
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js" />
24+
<Exec Command="node node_modules/webpack/bin/webpack.js" />
25+
</Target>
26+
27+
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
2028
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
2129
<Exec Command="npm install" />
2230
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod" />

templates/VueSpa/VueSpa.csproj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@
1616
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0-*" />
1717
</ItemGroup>
1818

19-
<Target Name="RunWebpack" AfterTargets="ComputeFilesToPublish">
19+
<Target Name="DebugRunWebpack" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('wwwroot\dist') ">
20+
<!-- In development, the dist files won't exist on the first run or when cloning to
21+
a different machine, so rebuild them if not already present. -->
22+
<Message Importance="high" Text="Performing first-run Webpack build..." />
23+
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js" />
24+
<Exec Command="node node_modules/webpack/bin/webpack.js" />
25+
</Target>
26+
27+
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
2028
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
2129
<Exec Command="npm install" />
2230
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod" />

0 commit comments

Comments
 (0)