Closed AlexVangelov closed 9 years ago
You should specify root directory.
/home/user/Projects/packman/
├─ path/to/file.html
└─ path/to/subfolder/file.html
Prefix prefix=/home/user/Projects/packman:[dirs]
will produce what you expect.
Or shorter version with same result:
prefix=packman:**
Yes, but using my proprietary project path in the config is not acceptable.
I found a temporary solution: (templates are living in <project>/src/
)
{ test: /\.html$/, loader: 'ng-cache?module=app,prefix=src:**' }
and it do the trick for me,
but it if somebody deploy the project into /home/user/src/<project>
the template /home/user/src/<project>/src/path/to/template.html
will not be parsed correctly.
If there is an option to apply wildcard on required path, not on resolved, it will be helpful.
Actually after reading the documentation, I was expecting something like this to work:
-url,prefix=**
or -url,prefix=[dirs]
It's not a problem because prefix takes the rightmost root
/home/user/src/<project>/src/path/to/template.html
with prefix prefix=src:**
produce path/to/template.html
-url,prefix=**
In my opinion this is dangerous. One day you can move script to another directory that will changes path in requires and in Angular cache, and breaks directives. Therefore, the path is formed relative to the specified root, and not relative to the script.
Oh, if the prefix takes rightmost occurrence of root folder, it's OK.
There will be no other src
folder in the project.
I agree that it's dangerous, but I have to Webpaket-ize existing project with Material Design
folder structure.
Thank you, can close the issue.
@teux I really see the use case of having prefix which takes the relative path in require. When group resources by feature, templates are located in the same or nested folders alongside with scripts. If move a component to another folder or change parent folder name the templateUrl
should reflect the changes. Having full path becomes annoying to maintain template urls when application has couple thousand files. So this issue can be avoided with a relative path in template id.
How to keep the relative path folders with different depth? e.g.: require("path/to/file.html") -> $templateCache.put("path/to/file.html"... require("path/to/subfolder/file.html") -> $templateCache.put("path/to/subfolder/file.html"...
I didn't found a way to do it for webpack config and available prefix options. { test: /.html$/, loader: 'ng-cache?module=app,prefix=???' }, Thank you.