{"id":20195,"library":"lodash-template-webpack-loader","title":"lodash-template-webpack-loader","description":"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.","status":"maintenance","version":"1.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/kmck/lodash-template-webpack-loader","tags":["javascript","underscore","lodash","template","webpack","loader"],"install":[{"cmd":"npm install lodash-template-webpack-loader","lang":"bash","label":"npm"},{"cmd":"yarn add lodash-template-webpack-loader","lang":"bash","label":"yarn"},{"cmd":"pnpm add lodash-template-webpack-loader","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used as default template engine (unless overridden by 'engine' or 'globalLodash')","package":"lodash","optional":true},{"reason":"Peer dependency – loader requires webpack to function","package":"webpack","optional":false}],"imports":[{"note":"This is a webpack loader, not a JS module. It is referenced by the string 'lodash-template-webpack' in webpack config loaders array.","wrong":"import lodashTemplateWebpack from 'lodash-template-webpack'","symbol":"lodash-template-webpack","correct":"module.exports = { module: { loaders: [{ test: /\\.tpl$/, loader: 'lodash-template-webpack' }] } }"}],"quickstart":{"code":"// webpack.config.js\nconst path = require('path');\nmodule.exports = {\n  entry: './src/index.js',\n  output: { filename: 'bundle.js', path: path.resolve(__dirname, 'dist') },\n  module: {\n    loaders: [\n      { test: /\\.tpl$/, loader: 'lodash-template-webpack' }\n    ]\n  },\n  lodashTemplateLoader: {\n    engine: 'lodash',\n    importsModule: path.join(__dirname, 'template-imports')\n  }\n};\n\n// template-imports.js\nmodule.exports = {\n  scream: function(str) { return (str || '').toUpperCase(); }\n};\n\n// src/index.js\nvar template = require('./template.tpl');\ndocument.body.innerHTML = template({ title: 'Hello' });\n\n// template.tpl\n<h1><%= title %></h1>\n<p><%- scream('hello') %></p>","lang":"javascript","description":"Shows webpack config, template imports module, and usage in a JS file with Lodash template syntax."},"warnings":[{"fix":"Use webpack 1 or switch to a maintained loader like 'html-loader' or 'raw-loader'.","message":"The loader works only with webpack 1.x; not compatible with webpack 2+ by default.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Set imports via 'importsModule' or 'imports' config option instead.","message":"Setting _.templateSettings.imports AFTER require-ing a template will NOT work.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use 'options' property within loader rule in webpack 2+, not top-level lodashTemplateLoader.","message":"The 'lodashTemplateLoader' config object is a custom non-standard webpack key.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install lodash --save-dev OR set globalLodash: true in loader options.","cause":"Lodash not installed or not in node_modules; loader requires lodash unless globalLodash is set.","error":"Module build failed: Error: Cannot find module 'lodash'"},{"fix":"Use webpack 1, or patch loader source; consider alternative.","cause":"Using webpack version that deprecated parseQuery; the loader uses old API.","error":"DeprecationWarning: loaderUtils.parseQuery is deprecated"},{"fix":"Ensure test regex matches file extension and loader name is correct.","cause":"Webpack rule not matching .tpl files or loader not configured correctly.","error":"Error: Cannot find module './path/to/template.tpl'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}