Skip to content

Linking an image outside of app root #6332

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

Closed
CSchulz opened this issue May 16, 2017 · 6 comments
Closed

Linking an image outside of app root #6332

CSchulz opened this issue May 16, 2017 · 6 comments

Comments

@CSchulz
Copy link

CSchulz commented May 16, 2017

Bug Report or Feature Request (mark with an x)

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

Versions.

node: 6.9.5
os: win32 x64
@angular/animations: 4.1.2
@angular/common: 4.1.2
@angular/compiler: 4.1.2
@angular/core: 4.1.2
@angular/forms: 4.1.2
@angular/http: 4.1.2
@angular/platform-browser: 4.1.2
@angular/platform-browser-dynamic: 4.1.2
@angular/router: 4.1.2
@angular/cli: 1.1.0-rc.0
@angular/compiler-cli: 4.1.2

Repro steps.

  1. create a component under app
  2. create a folder resources/icons in the project root and put an image in that directory
  3. in the template link the image

Additional information

I have tried different ways all without success:

<img src="assets/icons/monitor.png">
<img src="resources/icons/monitor.png">
<img src="../resources/icons/monitor.png">
<img src="icons/monitor.png">

You can see no resources from icons are included:
image

The css is included via the styles of angular-cli.json.

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "version": "0.0.1",
    "name": "test"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "../resources",
        "../resources/icons/favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "",
      "styles": [
        "../node_modules/bootstrap/dist/css/bootstrap.min.css",
        "../node_modules/primeng/resources/primeng.min.css",
        "../node_modules/primeng/resources/themes/bootstrap/theme.css",
        "../node_modules/font-awesome/css/font-awesome.min.css",
        "../resources/css/test.css"
      ],
      "scripts": [],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],

Related to #3292

Desired functionality.

The image should be found out side of the app root directory f.e. src.
The assets array should be used for ng serve too.

@clydin
Copy link
Member

clydin commented May 16, 2017

ng serve essentially performs an ng build in memory so the assets configured in .angular-cli.json should be available. Which also means that the output of ng build can be used to preview what is available via ng serve.

Can you provide your .angular-cli.json file?

@sumitarora sumitarora self-assigned this May 16, 2017
@sumitarora sumitarora added needs: investigation Requires some digging to determine if action is needed and removed needs: investigation Requires some digging to determine if action is needed labels May 16, 2017
@sumitarora
Copy link
Contributor

@CSchulz You can specify custom folders as { "glob": "**/*", "input": "../resources/", "output": "./resources/" }, Please see the story for more details https://github.com/angular/angular-cli/wiki/stories-asset-configuration

@CSchulz
Copy link
Author

CSchulz commented May 16, 2017

I was expecting that ../resources would be the short form like assets for { "glob": "**/*", "input": "./assets/", "output": "./assets/" }

I can't find anything special for assets in the https://github.com/angular/angular-cli/blob/master/packages/%40angular/cli/plugins/glob-copy-webpack-plugin.ts .

Why is there a different behavior?

@sumitarora
Copy link
Contributor

@CSchulz
Copy link
Author

CSchulz commented May 25, 2017

Yes for sure, but why is there different behavior?

@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 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants