asset path must start with the project source root

See original GitHub issue

Versions

Angular CLI: 6.0.1
Node: 9.2.0
OS: darwin x64
Angular: 6.0.2
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.1
@angular-devkit/build-angular     0.6.1
@angular-devkit/build-optimizer   0.6.1
@angular-devkit/core              0.6.1
@angular-devkit/schematics        0.6.1
@angular/cdk                      5.2.5
@angular/cli                      6.0.1
@angular/flex-layout              6.0.0-beta.15
@angular/material                 5.2.5
@ngtools/webpack                  6.0.1
@schematics/angular               0.6.1
@schematics/update                0.6.1
rxjs                              6.1.0
typescript                        2.7.2
webpack                           4.6.0

Repro steps

I have a nrwl/nx repository which I migrated. The Angular CLI update script migrated my .angular-cli.json in the following way (excerpt of one of the projects in my monorepo):

"securplan-web": {
    "root": "",
    "sourceRoot": "src",
    "projectType": "application",
    "architect": {
    "build": {
        "builder": "@angular-devkit/build-angular:browser",
        "options": {
        "outputPath": "dist/apps/securplan-web",
        "index": "apps/securplan-web/src/index.html",
        "main": "apps/securplan-web/src/main.ts",
        "tsConfig": "apps/securplan-web/src/tsconfig.app.json",
        "polyfills": "apps/securplan-web/src/polyfills.ts",
        "assets": ["apps/securplan-web/src/assets", "apps/securplan-web/src/favicon.ico"],
        "styles": ["apps/securplan-web/src/assets/style/material-icons.css", "apps/securplan-web/src/styles.scss"],
        "scripts": []
        },
       ...
    }
...
}

Note the assets configuration. If I try to build or serve this project I get the error

The apps/securplan-web/src/assets asset path must start with the project source root.

Changing the path from

 "assets": ["apps/securplan-web/src/assets", "apps/securplan-web/src/favicon.ico"],

to

"assets": ["assets", "favicon.ico"],

doesn’t work and results in this error:

The assets asset path must start with the project source root.

What works is if I change it like this:

"assets": [
  { "input": "apps/securplan-web/src/assets", "glob": "**/*", "output": "assets" },
  { "input": "apps/securplan-web/src", "glob": "favicon.ico", "output": "." }
],

Observed behavior

(as described before in the repro steps)

Desired behavior

Although the “explicit” form of defining the assets paths works, the error message is very misleading and kinda strange, since my path is actually inside the project source root, especially when then changing it to "assets": ["assets", "favicon.ico"],

Mention any other details that might be useful (optional)

This might be related to #10688 although it’s not exactly the same use case.

//cc FYI @clydin

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
FrozenPandazcommented, May 30, 2018

Made a PR to fix this 😃

https://github.com/angular/devkit/pull/985

3reactions
filipesilvacommented, May 17, 2018

@juristr I think I know what happened here. Something in the project structure broke the paths when updating the .angular-cli.json file. Specifically, root and sourceRoot are not correct for that project.

It should be this instead:

"securplan-web": {
    "root": "apps/securplan-web/",
    "sourceRoot": "apps/securplan-web/src/",
    "projectType": "application",

Can you provide us with a reproduction of this problem happening? The old .angular-cli.json should be enough.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular Upgrade From 5 to 6: asset path must start with the ...
I received the The src/assets asset path must start with the project source root error message after adding ...
Read more >
The favicon.ico asset path must start with the project source root
I was trying to start the project with "ng serve" and I've got the following error: "The favicon.ico asset path must start with...
Read more >
asset path must start with the project source root – iTecNote
I upgraded my existing app from Angular 5 to 6. path must start with the project source root. As you can see below...
Read more >
asset path must start with the project source root #16979
asset path must start with the project source root #16979 ... Describe the bug Using storybook in a nx workspace but without the...
Read more >
angular json asset path must start with the project source root
angular json asset path must start with the project source root ... At the top level of angular.json, a few properties configure the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found