Webpack loader that bundles AngularJS templates into the JavaScript bundle and pre-populates the $templateCache, eliminating initial load time for templates. Version 2.1.0 is stable, with maintenance releases on GitHub. Key differentiators: it does not minify/process HTML, instead working with html-loader or raw-loader for flexibility; supports parameter interpolation via webpack loader-utils; handles module, relativeTo, prefix, and pathSep options for path customization.
npm install ngtemplate-loaderVerified import paths — ran on the pinned version, not inferred.
Shows webpack configuration to load .html files with ngtemplate-loader and html-loader, and usage in an AngularJS directive via require.
Move the require() call outside the directive function, e.g., assign to a variable at the top of the module file.
Define a module rule for .html files that uses ngtemplate-loader and html-loader, then use simple require('./file.html') without inline loaders.Ensure the relativeTo path matches a prefix of the absolute path of the source file, or use 'prefix' option alone.
Run 'npm install ngtemplate-loader --save-dev' and ensure node_modules is in the resolve path.