-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write import map to html files #46233
base: main
Are you sure you want to change the base?
Changes from all commits
e882406
ef4843e
3550dc0
fcf527f
a4582e2
ca1578d
ea7f7fd
1d8d137
fab6429
9709397
45bf5d7
b212724
79e5fb7
ebd6e55
c31496e
25a271f
961c36e
f0d4ea4
1221414
b5ee5a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
<!-- | ||
*********************************************************************************************** | ||
Microsoft.NET.Sdk.StaticWebAssets.HtmlImportMap.targets | ||
|
||
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have | ||
created a backup copy. Incorrect changes to this file will make it | ||
impossible to load or build your projects from the command-line or the IDE. | ||
|
||
Copyright (c) .NET Foundation. All rights reserved. | ||
*********************************************************************************************** | ||
--> | ||
|
||
<Project ToolsVersion="14.0"> | ||
|
||
<UsingTask TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.WriteImportMapToHtml" AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)" /> | ||
|
||
<PropertyGroup> | ||
|
||
<!-- | ||
ResolveBuildRelatedStaticWebAssets | ||
ResolveHtmlImportMapBuildStaticWebAssets | ||
GenerateHtmlImportMapBuildStaticWebAssets | ||
ResolveHtmlImportMapBuildConfiguration | ||
--> | ||
<ResolveBuildRelatedStaticWebAssetsDependsOn> | ||
$(ResolveBuildRelatedStaticWebAssetsDependsOn); | ||
ResolveHtmlImportMapBuildStaticWebAssets; | ||
</ResolveBuildRelatedStaticWebAssetsDependsOn> | ||
<ResolveCompressedFilesDependsOn> | ||
$(ResolveCompressedFilesDependsOn); | ||
ResolveHtmlImportMapBuildStaticWebAssets | ||
</ResolveCompressedFilesDependsOn> | ||
<ResolveHtmlImportMapBuildStaticWebAssetsDependsOn> | ||
GenerateHtmlImportMapBuildStaticWebAssets; | ||
$(ResolveHtmlImportMapBuildStaticWebAssetsDependsOn) | ||
</ResolveHtmlImportMapBuildStaticWebAssetsDependsOn> | ||
<GenerateHtmlImportMapBuildStaticWebAssetsDependsOn> | ||
ResolveHtmlImportMapBuildConfiguration; | ||
$(GenerateHtmlImportMapBuildStaticWebAssetsDependsOn) | ||
</GenerateHtmlImportMapBuildStaticWebAssetsDependsOn> | ||
|
||
<!-- | ||
ResolvePublishRelatedStaticWebAssets | ||
ResolveHtmlImportMapPublishStaticWebAssets | ||
GenerateHtmlImportMapPublishStaticWebAssets | ||
ResolveHtmlImportMapPublishConfiguration | ||
--> | ||
<ResolvePublishRelatedStaticWebAssetsDependsOn> | ||
$(ResolvePublishRelatedStaticWebAssetsDependsOn); | ||
ResolveHtmlImportMapPublishStaticWebAssets | ||
</ResolvePublishRelatedStaticWebAssetsDependsOn> | ||
<ResolveHtmlImportMapPublishStaticWebAssetsDependsOn> | ||
GenerateHtmlImportMapPublishStaticWebAssets; | ||
$(ResolveHtmlImportMapPublishStaticWebAssetsDependsOn) | ||
</ResolveHtmlImportMapPublishStaticWebAssetsDependsOn> | ||
<GenerateHtmlImportMapPublishStaticWebAssetsDependsOn> | ||
ResolveHtmlImportMapPublishConfiguration; | ||
$(GenerateHtmlImportMapPublishStaticWebAssetsDependsOn) | ||
</GenerateHtmlImportMapPublishStaticWebAssetsDependsOn> | ||
Comment on lines
+25
to
+59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to ensure that this runs before the service worker is generated. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also needs to run before compression happens |
||
|
||
</PropertyGroup> | ||
|
||
<!-- Build --> | ||
|
||
<Target Name="ResolveHtmlImportMapBuildConfiguration"> | ||
<PropertyGroup> | ||
<_BuildImportMapHtmlPath>$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'importmaphtml', 'build'))</_BuildImportMapHtmlPath> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
</PropertyGroup> | ||
|
||
<MakeDir Directories="$(_BuildImportMapHtmlPath)"/> | ||
|
||
<ItemGroup> | ||
<_HtmlStaticWebAssets Include="@(StaticWebAsset)" Condition="'%(AssetKind)' != 'Publish' and '%(Extension)' == '.html'" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also do older |
||
<_EsModuleCandidate Include="@(StaticWebAsset)" Condition="'%(AssetKind)' != 'Publish'" /> | ||
</ItemGroup> | ||
|
||
<FilterStaticWebAssetEndpoints Condition="'@(_EsModuleCandidate)' != ''" | ||
Endpoints="@(StaticWebAssetEndpoint)" | ||
Assets="@(_EsModuleCandidate)" | ||
Filters="" | ||
> | ||
<Output TaskParameter="FilteredEndpoints" ItemName="_EsModuleCandidateEndpoints" /> | ||
</FilterStaticWebAssetEndpoints> | ||
</Target> | ||
|
||
<Target Name="GenerateHtmlImportMapBuildStaticWebAssets" DependsOnTargets="$(GenerateHtmlImportMapBuildStaticWebAssetsDependsOn)"> | ||
<WriteImportMapToHtml | ||
Endpoints="@(_EsModuleCandidateEndpoints)" | ||
HtmlFiles="@(_HtmlStaticWebAssets)" | ||
OutputPath="$(_BuildImportMapHtmlPath)"> | ||
<Output TaskParameter="HtmlCandidates" ItemName="_HtmlCandidates" /> | ||
<Output TaskParameter="HtmlFilesToRemove" ItemName="_HtmlFilesToRemove" /> | ||
<Output TaskParameter="FileWrites" ItemName="FileWrites" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this friendly to incremental build ? |
||
</WriteImportMapToHtml> | ||
</Target> | ||
|
||
<Target Name="ResolveHtmlImportMapBuildStaticWebAssets" DependsOnTargets="$(ResolveHtmlImportMapBuildStaticWebAssetsDependsOn)"> | ||
<ItemGroup> | ||
<_HtmlCandidatesNoMetadata | ||
Include="@(_HtmlCandidates)" | ||
RemoveMetadata="SourceType;AssetKind;Integrity;Fingerprint" /> | ||
<_HtmlCandidatesNoMetadata ContentRoot="$(_BuildImportMapHtmlPath)" /> | ||
</ItemGroup> | ||
<DefineStaticWebAssets CandidateAssets="@(_HtmlCandidatesNoMetadata)" | ||
SourceType="Computed" | ||
AssetKind="Build" | ||
> | ||
<Output TaskParameter="Assets" ItemName="_UpdatedHtmlStaticWebAssets" /> | ||
</DefineStaticWebAssets> | ||
<DefineStaticWebAssetEndpoints | ||
CandidateAssets="@(_UpdatedHtmlStaticWebAssets)" | ||
ExistingEndpoints="@(StaticWebAssetEndpoint)" | ||
ContentTypeMappings="@(StaticWebAssetContentTypeMapping)" | ||
> | ||
<Output TaskParameter="Endpoints" ItemName="_UpdatedHtmlStaticWebAssetsEndpoint" /> | ||
</DefineStaticWebAssetEndpoints> | ||
<ItemGroup> | ||
<StaticWebAsset Remove="@(_HtmlFilesToRemove)" /> | ||
<StaticWebAsset Include="@(_UpdatedHtmlStaticWebAssets)" /> | ||
<StaticWebAssetEndpoint Include="@(_UpdatedHtmlStaticWebAssetsEndpoint)" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we remove the old endpoints too? |
||
</ItemGroup> | ||
</Target> | ||
|
||
<!-- Publish --> | ||
|
||
<Target Name="ResolveHtmlImportMapPublishConfiguration"> | ||
<PropertyGroup> | ||
<_PublishImportMapHtmlPath>$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'importmaphtml', 'publish'))</_PublishImportMapHtmlPath> | ||
</PropertyGroup> | ||
|
||
<MakeDir Directories="$(_PublishImportMapHtmlPath)"/> | ||
|
||
<ItemGroup> | ||
<_EsModuleCandidateForPublish Include="@(StaticWebAsset)" Condition="'%(AssetKind)' != 'Build'" /> | ||
</ItemGroup> | ||
|
||
<FilterStaticWebAssetEndpoints Condition="'@(_EsModuleCandidateForPublish)' != ''" | ||
Endpoints="@(StaticWebAssetEndpoint)" | ||
Assets="@(_EsModuleCandidateForPublish)" | ||
Filters="" | ||
> | ||
<Output TaskParameter="FilteredEndpoints" ItemName="_EsModuleCandidateForPublishEndpoints" /> | ||
</FilterStaticWebAssetEndpoints> | ||
</Target> | ||
|
||
<Target Name="GenerateHtmlImportMapPublishStaticWebAssets" DependsOnTargets="$(GenerateHtmlImportMapPublishStaticWebAssetsDependsOn)"> | ||
<WriteImportMapToHtml | ||
Endpoints="@(_EsModuleCandidateForPublishEndpoints)" | ||
HtmlFiles="@(_HtmlStaticWebAssets)" | ||
OutputPath="$(_PublishImportMapHtmlPath)"> | ||
<Output TaskParameter="HtmlCandidates" ItemName="_HtmlPublishCandidates" /> | ||
<Output TaskParameter="HtmlFilesToRemove" ItemName="_HtmlPublishFilesToRemove" /> | ||
<Output TaskParameter="FileWrites" ItemName="FileWrites" /> | ||
</WriteImportMapToHtml> | ||
</Target> | ||
|
||
<Target Name="ResolveHtmlImportMapPublishStaticWebAssets" DependsOnTargets="$(ResolveHtmlImportMapPublishStaticWebAssetsDependsOn)"> | ||
<ItemGroup> | ||
<_HtmlPublishCandidatesNoMetadata | ||
Include="@(_HtmlPublishCandidates)" | ||
RemoveMetadata="SourceType;AssetKind;Integrity;Fingerprint" /> | ||
<_HtmlPublishCandidatesNoMetadata ContentRoot="$(_PublishImportMapHtmlPath)" /> | ||
</ItemGroup> | ||
<DefineStaticWebAssets CandidateAssets="@(_HtmlPublishCandidatesNoMetadata)" | ||
SourceType="Computed" | ||
AssetKind="Publish" | ||
> | ||
<Output TaskParameter="Assets" ItemName="_UpdatedHtmlPublishStaticWebAssets" /> | ||
</DefineStaticWebAssets> | ||
<DefineStaticWebAssetEndpoints | ||
CandidateAssets="@(_UpdatedHtmlPublishStaticWebAssets)" | ||
ExistingEndpoints="@(StaticWebAssetEndpoint)" | ||
ContentTypeMappings="@(StaticWebAssetContentTypeMapping)" | ||
> | ||
<Output TaskParameter="Endpoints" ItemName="_UpdatedHtmlPublishStaticWebAssetsEndpoint" /> | ||
</DefineStaticWebAssetEndpoints> | ||
<ItemGroup> | ||
<StaticWebAsset Remove="@(_HtmlPublishFilesToRemove)" /> | ||
<StaticWebAsset Include="@(_UpdatedHtmlPublishStaticWebAssets)" /> | ||
<StaticWebAssetEndpoint Include="@(_UpdatedHtmlPublishStaticWebAssetsEndpoint)" /> | ||
</ItemGroup> | ||
</Target> | ||
|
||
</Project> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is explaining the execution order ? Maybe you can clarify that