Webpack loader that compiles Twig templates into an HTML string using Twig.js. Version 0.1.9 is the latest stable release (last updated 2019). It integrates with webpack to process .twig files, supports data injection, caching, namespaces, and custom Twig extensions (functions, filters, tests, tags). Compared to alternatives like twig-loader, it returns raw HTML string rather than a compiled template function, which simplifies usage with html-webpack-plugin. Requires raw-loader as a peer dependency. Low maintenance cadence (no updates since 2019).
npm install twig-html-loaderVerified import paths — ran on the pinned version, not inferred.
webpack config to compile Twig templates to HTML strings using raw-loader and twig-html-loader.
Add 'raw-loader' before 'twig-html-loader' in the use array.
Use context.addDependency() as shown in the README watch-data example.
Always include raw-loader before twig-html-loader.
Add 'raw-loader' to the use array before 'twig-html-loader'.
Install twig as a dependency: npm install twig --save-dev