A webpack loader for Angular 2+ applications that inlines template URLs and style URLs into component metadata at build time. It replaces templateUrl and styleUrls declarations in Angular component decorators with synchronous require() calls, enabling bundling of HTML templates and CSS styles. Currently at version 0.6.2, this package is in maintenance mode and is primarily used with older Angular versions and webpack configurations. It requires a separate loader (e.g., raw-loader) to handle .html and .css files. Alternatives include the Angular CLI's built-in handling or @ngtools/webpack.
npm install angular2-template-loaderVerified import paths — ran on the pinned version, not inferred.
Configures webpack to use angular2-template-loader to inline templateUrl and styleUrls into components.
Use Angular CLI or @ngtools/webpack for AoT builds; or use angular2-template-loader with JiT only.
Migrate to Angular CLI or use @ngtools/webpack for new projects.
Install @types/node or @types/requirejs, or declare var require: any; in a global declaration file.
Add appropriate loaders for file types when keepUrl=true, e.g., file-loader.
Upgrade to version 0.5.0+ which added support for inline styles via require() in styles array.
Install raw-loader: npm install raw-loader --save-dev and add rule for .html and .css files.
Ensure the template file path is correct and exists, or use absolute paths.