devkit icon indicating copy to clipboard operation
devkit copied to clipboard

baseHref/deployUrl option for universal build in @angular-devkit/build-angular:server

Open nishesj opened this issue 8 years ago • 1 comments

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Area

- [ x] devkit
- [ ] schematics

Versions

angular-devkit/architect 0.6.5

Repro steps

Cannot pass baseHref or deployUrl option when running ng run web:server:production which contains

 "server": {
          "builder": "@angular-devkit/build-angular:server",
          "options": {
            "outputPath": "dist/server",
            "main": "src/main.server.ts",
            "tsConfig": "src/tsconfig.server.json"
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ]
            }
          }
        }

Which causes wrong assets path in css on the universal generated response. Where as when doing a browser build the baseHref is properly appended in postCss processing as expected. baseHref set to "https://cdn.example.com"


  .icon {
     background: url('/assets/icon.svg') no-repeat center center;
   }

angular-devkit/build-angular:browser-> postCss ->

 .icon {
    background: url('https://cdn.example.com/assets/icon.svg') no-repeat center center;
  }

angular-devkit/build-angular:server -> postCss -> no change which leads to wrong URL in first initial server rendered response in combination to html base href tag

Desired functionality

The postcss step in server build should append the path with baseUrl or deployUrl as in browserBuild so that the initial response generated by universal has correct path to assets if relative URL is used

nishesj avatar May 30 '18 09:05 nishesj

This issue was moved to angular/angular-cli#12093

alexeagle avatar Sep 04 '18 23:09 alexeagle