简体   繁体   中英

Azure and Angular app using web.config are not versioning depending on URL route (two live versions)

I'm using Angular 6 with Azure VSTS pipeline to upload my app on my server. I correctly added the web.config in the "src" folder and added in angular.json in assets section "src/web.config".

I can tell this is working because if i change the url i doesn't have the error which was occurring before "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."

However, the versioning (prevent caching) seems to work only on any resource like these : "www.app.net/home" or "www.app.net/support". I can see in the chrome sources file that all JS files have the hashed filename.

If i browse only : "www.app.net" the redirect work but for some reason all the js are not minified and doesn't have filename hashed like if it was an old version or not in production.

I don't understand how can i have like two live version depending on the url which is the same app service in the end and always publishing at the same place.

EDIT: I thought that publish erase the content but all version stay there. Should i clean the azure wwwroot app before release a new version ? all version is stacking up in the folder

My routermodule is :

    RouterModule.forRoot([
  { path: '', redirectTo:'home',  pathMatch: 'full' },
  { path: 'home', component: HomeComponent, pathMatch: 'full' },
  { path: 'support', component: SupportComponent, pathMatch: 'full' },
])

My web.config is :

<configuration>
<system.webServer>
  <rewrite>
    <rules>
      <rule name="Angular" stopProcessing="true">
        <match url=".*" />
        <conditions logicalGrouping="MatchAll">
          <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
          <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        </conditions>
        <action type="Rewrite" url="/" />
      </rule>
    </rules>
  </rewrite>
</system.webServer>

I only needed to remove all the files before publishing.

To do so in your "Azure App Service Deploy " Task check "Remove additional files at destination" in "Additional Deployment Options". You may have to check "publish using web deploy" at first!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM