Registry / devops / lodash-template-webpack-loader

lodash-template-webpack-loader

JSON →
library1.0.2jsnpmunverified

Webpack loader that compiles Lodash/Underscore templates into functions. Version 1.0.2, stable, last updated 2016. Supports interpolation (<%= %>), escape (<%- %>), evaluation (<% %>), template settings (imports, variable, custom delimiters), and optional global or engine-based Lodash. Notable for its simplicity and customizability without bundling full Lodash unless desired. No known active development or maintenance.

npm install lodash-template-webpack-loader
INSTALL
IMPORT
SIG · LODASH-TEMPLATE-WE
L
lodash-template-webpack-loader
devopsjavascriptv1.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

lodash-template-webpack
module.exports = { module: { loaders: [{ test: /\.tpl$/, loader: 'lodash-template-webpack' }] } }
import lodashTemplateWebpack from 'lodash-template-webpack'
This is a webpack loader, not a JS module. It is referenced by the string 'lodash-template-webpack' in webpack config loaders array.

Shows webpack config, template imports module, and usage in a JS file with Lodash template syntax.

// webpack.config.js const path = require('path'); module.exports = { entry: './src/index.js', output: { filename: 'bundle.js', path: path.resolve(__dirname, 'dist') }, module: { loaders: [ { test: /\.tpl$/, loader: 'lodash-template-webpack' } ] }, lodashTemplateLoader: { engine: 'lodash', importsModule: path.join(__dirname, 'template-imports') } }; // template-imports.js module.exports = { scream: function(str) { return (str || '').toUpperCase(); } }; // src/index.js var template = require('./template.tpl'); document.body.innerHTML = template({ title: 'Hello' }); // template.tpl <h1><%= title %></h1> <p><%- scream('hello') %></p>
Debug
Known issues
breakingThe loader works only with webpack 1.x; not compatible with webpack 2+ by default.
fix
Use webpack 1 or switch to a maintained loader like 'html-loader' or 'raw-loader'.
affects: >=1.0.0
gotchaSetting _.templateSettings.imports AFTER require-ing a template will NOT work.
fix
Set imports via 'importsModule' or 'imports' config option instead.
affects: >=1.0.0
deprecatedThe 'lodashTemplateLoader' config object is a custom non-standard webpack key.
fix
Use 'options' property within loader rule in webpack 2+, not top-level lodashTemplateLoader.
affects: >=1.0.0
Errors
Common errors & fixes
Module build failed: Error: Cannot find module 'lodash'
Lodash not installed or not in node_modules; loader requires lodash unless globalLodash is set.
fix
npm install lodash --save-dev OR set globalLodash: true in loader options.
DeprecationWarning: loaderUtils.parseQuery is deprecated
Using webpack version that deprecated parseQuery; the loader uses old API.
fix
Use webpack 1, or patch loader source; consider alternative.
Error: Cannot find module './path/to/template.tpl'
Webpack rule not matching .tpl files or loader not configured correctly.
fix
Ensure test regex matches file extension and loader name is correct.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
lodashoptionalUsed as default template engine (unless overridden by 'engine' or 'globalLodash')
webpackrequiredPeer dependency – loader requires webpack to function
Agent activity
2 hits · last 30 days
node
2
Resources
lodash-template-webpack-loader — npm install lodash-template-webpack-loader · libregistry