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

Relative path for assets array in angular-cli.json file not working #2933

Closed
maxailloud opened this issue Oct 28, 2016 · 6 comments
Closed

Comments

@maxailloud
Copy link

Hi guys,

Using relative path for dealing with assets is not working. For example if I want to use images as my assets from a node module folder.

OS?

Mac OSX Sierra

Versions.

angular-cli: 1.0.0-beta.18
node: 6.8.1
os: darwin x64

Repro steps.

This is what my angular-cli.json file looks like:

{
  "project": {
    "version": "1.0.0-beta.18",
    "name": "project_name"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "build",
      "assets": [
          "assets",
          "../node_modules/my_module/assets"
      ],
      "index": "index.html",
      "main": "main.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.json",
      "prefix": "app",
      "mobile": false,
      "styles": [
        "bootstrap.scss",
        "style.scss"
      ],
      "scripts": [
          "../node_modules/node-uuid/uuid.js"
      ],
      "environments": {
        "source": "environments/environment.ts",
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "addons": [],
  "packages": [],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "prefixInterfaces": false
  }
}

The log given by the failure.

No error, just the assets files from the node_modules folder aren't copied to the dist, build for me, one.

Mention any other details that might be useful.

In the case of relative path I think it should copy the files from the specified folder without keeping the hierarchy. Just taking files and folder in it but without recreating the whole hierarchy of folder in the assets folder.

By the way images from the src/assets folder are correctly copied into dist.

So i don't know if it's known or not but I think it can be really useful, for me I'm creating packages for my app and some will have images in them.

@maxailloud
Copy link
Author

maxailloud commented Oct 31, 2016

Btw it's not working for both serveand buildcommand.
I can see the files from the node_modulesfolder being treated as assets when building, but not copied to the dist folder.

@filipesilva
Copy link
Contributor

This isn't a scenario that we want to support currently. The main reason against it is the final path. The current solution means to always keep your dir structure so that you can reference things via predictable static paths. This just isn't possible if you're looking to have things pulled over from outside the project.

My best recommendation is to copy over those assets to inside the project. If you don't want to have them there in the repo, you can add it to the gitignore.

@filipesilva
Copy link
Contributor

Followup feature request: #3555

@maxailloud
Copy link
Author

Sweet.
I ended up using a symlink to do that but if a built-in solution come it will be better.

@rtm
Copy link

rtm commented Apr 15, 2017

Instead of just ignoring/doing nothing, could a warning/error be displayed, such as

Attempt to bring in asset outside the project tree

@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.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants