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.
Mac OSX Sierra
angular-cli: 1.0.0-beta.18
node: 6.8.1
os: darwin x64
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
}
}
No error, just the assets files from the node_modules folder aren't copied to the dist, build for me, one.
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.
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.
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.
Followup feature request: https://github.com/angular/angular-cli/issues/3555
Sweet.
I ended up using a symlink to do that but if a built-in solution come it will be better.
Instead of just ignoring/doing nothing, could a warning/error be displayed, such as
Attempt to bring in asset outside the project tree
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._
Most helpful comment
Instead of just ignoring/doing nothing, could a warning/error be displayed, such as