Skip to content
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

--deploy-url not available on the server in CLI v6 #11426

Closed
mgol opened this issue Jul 2, 2018 · 3 comments · Fixed by #11442
Closed

--deploy-url not available on the server in CLI v6 #11426

mgol opened this issue Jul 2, 2018 · 3 comments · Fixed by #11442

Comments

@mgol
Copy link
Member

mgol commented Jul 2, 2018

Bug Report or Feature Request (mark with an x)

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

Area

- [ ] devkit
- [ ] schematics

Versions

$ node --version
v8.11.3
$ yarn --version
1.7.0

macOS High Sierra 10.13.5 (17F77)

Repro steps

See https://github.com/mgol/angular-deploy-url-bug.

The log given by the failure

No log but the browser will trigger 404 requests to invalid asset paths from the server-generated CSS. Once the client app loads, all works fine.

Desired functionality

The server should support the deployUrl setting in angular.json and the --deploy-url command line param again as in previous CLI versions.

CLI 6 only supports deployUrl for the browser & devServer targets.

Mention any other details that might be useful

Without --deploy-url support on the server, it's impossible to use consistent asset paths between the server and the client if --deploy-url is used on the client.

@mgol mgol changed the title --deploy-url not available on the server --deploy-url not available on the server in CLI v6 Jul 2, 2018
filipesilva added a commit to filipesilva/angular-cli that referenced this issue Jul 3, 2018
@daniloapa
Copy link

daniloapa commented Jul 17, 2018

I've updated my stack to the next rc version, which includes this deploy to /build-angular, but it appears it isn't working for me yet, despite server deploy-url config is accepted, it appears is not working yet, like the client app could retrieve all assets from same deploy-url config.

My dependencies are:

    "@angular/animations": "^6.1.0-rc.0",
    "@angular/common": "^6.1.0-rc.0",
    "@angular/compiler": "^6.1.0-rc.0",
    "@angular/core": "^6.1.0-rc.0",
    "@angular/forms": "^6.1.0-rc.0",
    "@angular/http": "^6.1.0-rc.0",
    "@angular/platform-browser": "^6.1.0-rc.0",
    "@angular/platform-browser-dynamic": "^6.1.0-rc.0",
    "@angular/platform-server": "^6.1.0-rc.0",
    "@angular/router": "^6.1.0-rc.0",
    "@nguniversal/module-map-ngfactory-loader": "^6.0.0",
    "ajv": "^6.5.2",
    "angular2-highcharts": "^0.5.5",
    "babel-cli": "^6.26.0",
    "babel-preset-es2015": "^6.24.1",
    "bootstrap": "^3.3.7",
    "core-js": "^2.5.7",
    "electron-to-chromium": "^1.3.52",
    "express": "^4.16.3",
    "font-awesome": "^4.7.0",
    "fs": "0.0.1-security",
    "highcharts": "^6.1.1",
    "hoek": "^5.0.3",
    "istanbul-api": "^1.3.1",
    "jquery": "^3.3.1",
    "lodash": "^4.17.10",
    "moment": "^2.22.2",
    "ng2-breadcrumbs": "^0.1.281",
    "npm-run-all": "^4.1.3",
    "popper.js": "^1.14.3",
    "prerender-node": "^3.1.1",
    "request": "^2.87.0",
    "rxjs": "^6.2.1",
    "rxjs-compat": "^6.2.1",
    "sshpk": "^1.14.2",
    "wp-api-angular": "^3.0.0-beta8",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.7.0-rc.2",
    "@angular/cli": "^6.1.0-rc.2",
    "@angular/compiler-cli": "^6.1.0-rc.0",
    "@angular/language-service": "^6.1.0-rc.0",
    "@nguniversal/express-engine": "^6.0.0",
    "@types/jasmine": "^2.8.8",
    "@types/node": "^10.5.2",
    "codelyzer": "^4.4.2",
    "enhanced-resolve": "^4.1.0",
    "jasmine-core": "^3.1.0",
    "jasmine-spec-reporter": "^4.2.1",
    "karma": "^2.0.4",
    "karma-chrome-launcher": "^2.2.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^2.0.1",
    "karma-jasmine": "^1.1.2",
    "karma-jasmine-html-reporter": "^1.2.0",
    "protractor": "^5.3.2",
    "ts-node": "^7.0.0",
    "tslint": "^5.10.0",
    "typescript": "^2.7.2"
  }```


angular.json
```{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "my-app": {
      "root": "src",
      "sourceRoot": "src",
      "projectType": "application",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist",
            "deployUrl": "/static/app/fundo/",
            "index": "src/index.html",
            "main": "src/main.ts",
            "tsConfig": "src/tsconfig.app.json",
            "polyfills": "src/polyfills.ts",
            "assets": [
              "src/assets",
            ],
            "styles": [
              "node_modules/bootstrap/dist/css/bootstrap.min.cass",
              "src/styles.scss"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "node_modules/bootstrap/dist/js/bootstrap.min.js"
            ]
          },
          "configurations": {
            "production": {
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "my-app:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "my-app:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "my-app:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "test.ts",
            "karmaConfig": "./karma.conf.js",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "node_modules/bootstrap/dist/js/bootstrap.min.js"
            ],
            "styles": [
              "node_modules/bootstrap/dist/css/bootstrap.min.css",
              "src/styles.scss"
            ],
            "assets": [
              "src/assets",
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json",
              "e2e/tsconfig.e2e.json"
            ],
            "exclude": []
          }
        },
        "server": {
          "builder": "@angular-devkit/build-angular:server",
          "options": {
            "outputPath": "dist-server",
            "deployUrl": "/static/app/fundo/",
            "main": "src/main.server.ts",
            "tsConfig": "src/tsconfig.server.json"
          }
        }
      }
    },
    "my-app-e2e": {
      "root": "",
      "sourceRoot": "e2e",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "./protractor.conf.js",
            "devServerTarget": "my-app:serve"
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "e2e/tsconfig.e2e.json"
            ],
            "exclude": []
          }
        }
      }
    }
  },
  "defaultProject": "my-app",
  "schematics": {
    "@schematics/angular:component": {
      "prefix": "app",
      "styleext": "css"
    },
    "@schematics/angular:directive": {
      "prefix": "app"
    }
  }
}

Is there anything else I'm forgeting?

Thanks,

@devbenzy
Copy link

devbenzy commented Jul 3, 2019

I've updated my stack to the next rc version, which includes this deploy to /build-angular, but it appears it isn't working for me yet, despite server deploy-url config is accepted, it appears is not working yet, like the client app could retrieve all assets from same deploy-url config.

My dependencies are:

    "@angular/animations": "^6.1.0-rc.0",
    "@angular/common": "^6.1.0-rc.0",
    "@angular/compiler": "^6.1.0-rc.0",
    "@angular/core": "^6.1.0-rc.0",
    "@angular/forms": "^6.1.0-rc.0",
    "@angular/http": "^6.1.0-rc.0",
    "@angular/platform-browser": "^6.1.0-rc.0",
    "@angular/platform-browser-dynamic": "^6.1.0-rc.0",
    "@angular/platform-server": "^6.1.0-rc.0",
    "@angular/router": "^6.1.0-rc.0",
    "@nguniversal/module-map-ngfactory-loader": "^6.0.0",
    "ajv": "^6.5.2",
    "angular2-highcharts": "^0.5.5",
    "babel-cli": "^6.26.0",
    "babel-preset-es2015": "^6.24.1",
    "bootstrap": "^3.3.7",
    "core-js": "^2.5.7",
    "electron-to-chromium": "^1.3.52",
    "express": "^4.16.3",
    "font-awesome": "^4.7.0",
    "fs": "0.0.1-security",
    "highcharts": "^6.1.1",
    "hoek": "^5.0.3",
    "istanbul-api": "^1.3.1",
    "jquery": "^3.3.1",
    "lodash": "^4.17.10",
    "moment": "^2.22.2",
    "ng2-breadcrumbs": "^0.1.281",
    "npm-run-all": "^4.1.3",
    "popper.js": "^1.14.3",
    "prerender-node": "^3.1.1",
    "request": "^2.87.0",
    "rxjs": "^6.2.1",
    "rxjs-compat": "^6.2.1",
    "sshpk": "^1.14.2",
    "wp-api-angular": "^3.0.0-beta8",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.7.0-rc.2",
    "@angular/cli": "^6.1.0-rc.2",
    "@angular/compiler-cli": "^6.1.0-rc.0",
    "@angular/language-service": "^6.1.0-rc.0",
    "@nguniversal/express-engine": "^6.0.0",
    "@types/jasmine": "^2.8.8",
    "@types/node": "^10.5.2",
    "codelyzer": "^4.4.2",
    "enhanced-resolve": "^4.1.0",
    "jasmine-core": "^3.1.0",
    "jasmine-spec-reporter": "^4.2.1",
    "karma": "^2.0.4",
    "karma-chrome-launcher": "^2.2.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^2.0.1",
    "karma-jasmine": "^1.1.2",
    "karma-jasmine-html-reporter": "^1.2.0",
    "protractor": "^5.3.2",
    "ts-node": "^7.0.0",
    "tslint": "^5.10.0",
    "typescript": "^2.7.2"
  }```


angular.json
```{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "my-app": {
      "root": "src",
      "sourceRoot": "src",
      "projectType": "application",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist",
            "deployUrl": "/static/app/fundo/",
            "index": "src/index.html",
            "main": "src/main.ts",
            "tsConfig": "src/tsconfig.app.json",
            "polyfills": "src/polyfills.ts",
            "assets": [
              "src/assets",
            ],
            "styles": [
              "node_modules/bootstrap/dist/css/bootstrap.min.cass",
              "src/styles.scss"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "node_modules/bootstrap/dist/js/bootstrap.min.js"
            ]
          },
          "configurations": {
            "production": {
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "my-app:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "my-app:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "my-app:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "test.ts",
            "karmaConfig": "./karma.conf.js",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "node_modules/bootstrap/dist/js/bootstrap.min.js"
            ],
            "styles": [
              "node_modules/bootstrap/dist/css/bootstrap.min.css",
              "src/styles.scss"
            ],
            "assets": [
              "src/assets",
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json",
              "e2e/tsconfig.e2e.json"
            ],
            "exclude": []
          }
        },
        "server": {
          "builder": "@angular-devkit/build-angular:server",
          "options": {
            "outputPath": "dist-server",
            "deployUrl": "/static/app/fundo/",
            "main": "src/main.server.ts",
            "tsConfig": "src/tsconfig.server.json"
          }
        }
      }
    },
    "my-app-e2e": {
      "root": "",
      "sourceRoot": "e2e",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "./protractor.conf.js",
            "devServerTarget": "my-app:serve"
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "e2e/tsconfig.e2e.json"
            ],
            "exclude": []
          }
        }
      }
    }
  },
  "defaultProject": "my-app",
  "schematics": {
    "@schematics/angular:component": {
      "prefix": "app",
      "styleext": "css"
    },
    "@schematics/angular:directive": {
      "prefix": "app"
    }
  }
}

Is there anything else I'm forgeting?

Thanks,

Is it possible to use cdn in angular universal ?

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants