Win10 x64
ng --version. If there's nothing outputted, please runnode --version and paste the result here:angular-cli: 1.0.0-beta.11-webpack
node: 5.10.1
os: win32 x64
a) Generate default project.
b) In app.component.ts, change the templateUrl to '/templates/app'
c) run ng build
ERROR in ./src/app/app.component.ts
Module not found: Error: Can't resolve './/templates/app' in 'D:\Dev\Junk\WebApplication19-Core-And-Angular-CLI\src\WebApplication19-Core-And-Angular-CLI\src\app'
@ ./src/app/app.component.ts 18:22-49
@ ./src/app/index.ts
@ ./src/main.ts
@ multi main
This worked fine in previous CLI versions using systemjs.
I believe this is because _something_ (maybe angular2-webpack-starter or similar) is attempting to inline the template. This will not work because the template is dynamically generated on the server.
This could potentially be fixed by editing the webpack.config - but the Angular CLI does not allow that.
Perhaps instead of an error, this could be a warning, and it could leave the templateUrl setting as-is.
I realize this is not so helpful for the problem you're describing, but it might be helpful as background information. I have been following Angular 2 for over a year now, and lost track of exactly where I read what. But I'm confident there's been discussion various places including in the issue tracker, from core A2 developers, indicating that they generally think of templates as a build time concern, not a runtime concern; that the current "platform dynamic" we are all using is primarily for development use, a placeholder until the template pre-compiler is ready. In other words, the thing you are doing, dynamic templates, may well turn out to be an edge case far from the target of mainline Angular 2 practice and tools. Perhaps will turn out that this is no longer correct, and that they do intend after all to encourage template compilation is a first-class production deployment path.
The concern that @kylecordes raised is very relevant - your setup will not work in precompilation.
But it's true that it's your problem if it doesn't, and the build system shouldn't stop you from putting whatever weird thing you want in templateUrl. I can't say this scenario is very high priority though.
We use https://github.com/TheLarkInn/angular2-template-loader to do this conversion. @TheLarkInn is there a reasonable way of not changing anything in case the template doesn't exist?
Does ng2 even support dynamic template urls to begin with? @filipesilva
In Just-in-Time compilation it does, because when the app tries to load the template it's already there. This isn't something we can support from within the CLI unfortunately, we do assume that these templates exist.
So is there any way to disable this strict templateUrl checking? I use angular with dynamic razor views (asp.net mvc) and it worked fine before, now I'd like to use webpack and it looks impossible, doesn't it?
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
So is there any way to disable this strict templateUrl checking? I use angular with dynamic razor views (asp.net mvc) and it worked fine before, now I'd like to use webpack and it looks impossible, doesn't it?