Consider using angular2-template-loader in templates/Angular2Spa #1340

Closed
opened 2025-08-09 17:19:45 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @colltoaction on 10/3/2016

Hi guys,

I just stumbled upon angular2-template-loader, and thought it's worth considering for this template (I'll definitely use it in my project from now on).

If you see some component's code like this you'll notice the template and styles are required. This is nice because we don't make as many requests compared to using templateUrl and styleUrls.

But there's a drawback: we're tying our code into Webpack. And that brings some issues like not being able to run the ngc compiler on our code. Surely someone's going to make it work at some point, but it's not working at the moment.

Using the mentioned loader, we're able to write plain Angular code like templateUrl: './app.component.html', while retaining all the benefits from bundling and transparency that Webpack provides.

I tested it and I can even require scss like styleUrls: ['./app.component.scss'], but as a side note, this probably won't work with ngc.

Thanks for your great support!

*Originally created by @colltoaction on 10/3/2016* Hi guys, I just stumbled upon `angular2-template-loader`, and thought it's worth considering for this template (I'll definitely use it in my project from now on). If you see some component's code like [this](https://github.com/aspnet/JavaScriptServices/blob/dev/templates/Angular2Spa/ClientApp/app/components/app/app.component.ts) you'll notice the template and styles are `require`d. This is nice because we don't make as many requests compared to using `templateUrl` and `styleUrls`. But there's a drawback: we're tying our code into Webpack. And that brings some issues like not being able to run the `ngc` compiler on our code. Surely someone's going to make it work at some point, but it's not working at the moment. Using the mentioned loader, we're able to write plain Angular code like `templateUrl: './app.component.html'`, while retaining all the benefits from bundling and transparency that Webpack provides. I tested it and I can even require scss like `styleUrls: ['./app.component.scss']`, but as a side note, this probably won't work with `ngc`. Thanks for your great support!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#1340
No description provided.