Solvedangular cli Problem with ng serve --preserve-symlinks Angular/CLI 6.0.0

Versions

Angular CLI: 6.0.0
Node: 8.11.1
OS: Windows 10 x64
Angular: 6.0.0

"@angular/animations": "6.0.0",
"@angular/cdk": "^6.0.1",
"@angular/cli": "^6.0.0",
"@angular/common": "6.0.0",
"@angular/compiler": "6.0.0",
"@angular/core": "6.0.0",
"@angular/flex-layout": "6.0.0-beta.15",
"@angular/forms": "6.0.0",
"@angular/http": "6.0.0",
"@angular/material": "^6.0.1",
"@angular/material-moment-adapter": "^6.0.0",
"@angular/platform-browser": "6.0.0",
"@angular/platform-browser-dynamic": "6.0.0",
"@angular/router": "6.0.0",
"@angular/service-worker": "6.0.0",

Repro steps

execute "ng serve --preserve-symlinks"

Observed behavior

Return error "Unknown option: '--preserveSymlinks'", was removed?

Desired behavior

Angular compile with symbolic link folders

Mention any other details that might be useful (optional)

image

19 Answers

✔️Accepted Answer

Seems that compile options have been removed. This post leads me to the solution: https://stackoverflow.com/questions/50177552/angular-cli-6-unknown-option-locale

I solved this by adding "preserveSymlinks": true in my angular.json file:

{ 
    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
    "version": 1,
    "newProjectRoot": "projects",
    "projects": {
        "my-project": {
            "root": "",
            "sourceRoot": "src",
            "projectType": "application",
            "architect": {
                "build": {
                    "builder": "@angular-devkit/build-angular:browser",
                    "options": {
                       "outputPath": "target",
                       "index": "src/index.html",
                       "main": "src/main.ts",
                       "tsConfig": "src/tsconfig.app.json",
                       "polyfills": "src/showcase/polyfills.ts",
                       "preserveSymlinks": true,
...

Other Answers:

It's not possible to add preserved symlinks to the build options in the angular.json when using library as projectType.

If you want to build a library with preserved symlinks you need to add
"preserveSymlinks": true to the angularCompilerOptions in tsconfig.lib.json.

e.g.

tsconfig.lib.json

"angularCompilerOptions": {
    "annotateForClosureCompiler": true,
    "skipTemplateCodegen": true,
    "strictMetadataEmit": true,
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true,
    "enableResourceInlining": true,
    "preserveSymlinks": true
  },

More Issues: