question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ng eject breaks asset loading

See original GitHub issue

Versions


    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/

Angular CLI: 1.6.6 (e)
Node: 8.1.2
OS: darwin x64
Angular: 5.2.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.6.6
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.6
@schematics/angular: 0.1.17
typescript: 2.6.2
webpack-dev-server: 2.11.1
webpack: 3.10.0

Repro steps

Step 1

Include an asset

app/index.html

// ..
                <img src="/assets/images/logo.png">
// ..

Step 2

Run ng serve

ng serve

Step 3

Observe the image is loaded correctly

Step 4

Eject the project

ng eject

Step 5

Run the project with the npm command

npm start

Observed behavior

The image is no longer loaded correctly.

logo.png:1 GET http://localhost:4200/assets/images/logo.png 404 (Not Found)

Desired behavior

The image is loaded in the same manner that the unejected project does.

EDIT

I have pinpointed the issue. The ng eject command creates the given CopyWebpackPublic config

new CopyWebpackPlugin([
            {
                "context": "src",
                "to": "",
                "from": {
                    "glob": "src/assets/**/*",
                    "dot": true
                }
            },
            {
                "context": "src",
                "to": "",
                "from": {
                    "glob": "src/favicon.ico",
                    "dot": true
                }
            }
        ], {
            "ignore": [
                ".gitkeep",
                "**/.DS_Store",
                "**/Thumbs.db"
            ],
            "debug": "warning"
        })

The problem is that the paths for assets and favicon.ico now contain the src/ directory. When renaming them to "assets/**/*" and "favicon.ico" it all works.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
bampakoacommented, Feb 1, 2018

I can confirm that it also happens in 1.6.7

3reactions
dragoufcommented, Feb 6, 2018

any fix ?

edit: ok, the fix was to remove ‘src’ from grlob path:

"from": {
      "glob": "src\\assets\\**\\*",
      "dot": true
}

to

"from": {
      "glob": "assets\\**\\*",
      "dot": true
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular CLI not coping images & fonts directory - Stack Overflow
I'm having trouble setting up my angular-cli.json to copy the fonts and images directories from the @cmsgov directory within my node_modules.
Read more >
angular/angular-cli - Gitter
ng eject or applying patch on angular/cli during post install ... @Apeteceume_twitter ugh. probably by removing modules to find out which one breaks....
Read more >
Paper Does Not Rewind or Eject After Scanning - HP Support
Paper does not rewind or eject after scanning due to incorrect settings in jet image software. After the scanning is complete, the paper...
Read more >
Core libraries, configuration and tools - Infinum
Run ng generate --help to see a list of all available options and schematics. ... config manually, you can eject the CLI's Webpack...
Read more >
Standard for the Administration of Immunizations
Snap the top off by breaking it away from ... For additional information related to oral vaccine administration via NG tube see link....
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