A webpack loader that compiles Mustache templates using Hogan.js. Current stable version is 1.4.3, with last release in 2016. It has peer dependencies on hogan.js and webpack (supports webpack 1.x, 2.x, and 4.x beta). Supports options like minification via html-minifier, tiny output, client-side compilation, and direct rendering. Differentiators include optional noShortcut for partials and render function for hot reloading. It is a straightforward conversion from Mustache templates to JavaScript functions, with minimal overhead.
npm install mustache-loaderVerified import paths — ran on the pinned version, not inferred.
Shows basic webpack configuration to use mustache-loader and how to import and use a compiled template.
Use module.rules array with use property for webpack 2+.
Specify exact webpack version range in your project.
Ensure mustache-loader is the last loader in the chain for those options to work.
Use 'render' option when using 'tiny' with HtmlWebpackPlugin.
Use a synchronous function or wrap in a data property.
Call template({}) directly instead of template.render({}). If you need partials, add '?noShortcut' to the loader.Run: npm install hogan.js
Use query string format e.g., 'mustache-loader?minify' or options object with only allowed keys: minify, noShortcut, clientSide, tiny, render.