{"id":42301,"library":"webpack-ejs3-loader","title":"webpack-ejs3-loader","description":"A webpack loader that compiles EJS templates into JavaScript functions at build time, with no frontend runtime dependencies. The current version 0.0.2 is a minor fork of compile-ejs-loader that upgrades dependencies and moves ejs, html-minifier, uglify-js, and loader-utils from devDependencies to dependencies for easier installation. It supports EJS compile options, optional HTML minification via html-minifier, and AST beautification via uglify-js. Works with webpack 4 and 5. Note that the package has very few downloads and may not receive updates.","status":"active","version":"0.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/t0lkman/webpack-ejs3-loader/","tags":["javascript"],"install":[{"cmd":"npm install webpack-ejs3-loader","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-ejs3-loader","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-ejs3-loader","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required to function as a loader","package":"webpack","optional":false}],"imports":[{"note":"The loader is used in webpack config or inline, not directly imported. This shows the import pattern when used with ECMAScript modules in webpack.","wrong":"const template = require('webpack-ejs3-loader!./file.ejs');","symbol":"default","correct":"import template from 'webpack-ejs3-loader!./file.ejs';"},{"note":"Use the modern webpack rule configuration (use) instead of legacy loaders array.","wrong":"module.exports = { module: { loaders: [ { test: /\\.ejs$/, loader: 'webpack-ejs3-loader' } ] } };","symbol":"Rule.use.loader","correct":"module.exports = { module: { rules: [ { test: /\\.ejs$/, use: { loader: 'webpack-ejs3-loader', options: { htmlmin: true } } } ] } };"},{"note":"When using with HtmlWebpackPlugin, specify the loader inline in the template path.","wrong":"new HtmlWebpackPlugin({ template: './templates/index.ejs', loader: 'webpack-ejs3-loader' })","symbol":"Plugin template","correct":"new HtmlWebpackPlugin({ template: 'webpack-ejs3-loader!./templates/index.ejs' })"}],"quickstart":{"code":"// webpack.config.js\nconst path = require('path');\nconst HtmlWebpackPlugin = require('html-webpack-plugin');\n\nmodule.exports = {\n  mode: 'development',\n  entry: './src/index.js',\n  output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.js' },\n  module: {\n    rules: [\n      {\n        test: /\\.ejs$/,\n        use: {\n          loader: 'webpack-ejs3-loader',\n          options: {\n            htmlmin: true,\n            htmlminOptions: { removeComments: true },\n          },\n        },\n      },\n    ],\n  },\n  plugins: [\n    new HtmlWebpackPlugin({\n      template: 'webpack-ejs3-loader!./src/template.ejs',\n      title: 'My App',\n    }),\n  ],\n};\n\n// src/template.ejs\n<!DOCTYPE html>\n<html>\n<head>\n  <title><%= title %></title>\n</head>\n<body>\n  <h1>Hello, <%= name %>!</h1>\n</body>\n</html>\n\n// src/index.js\nconst template = require('webpack-ejs3-loader!./template.ejs');\nconst html = template({ title: 'My App', name: 'World' });\nconsole.log(html);","lang":"javascript","description":"Shows how to configure webpack-ejs3-loader in webpack config and use it both as a rule for .ejs files and inline with HtmlWebpackPlugin."},"warnings":[{"fix":"Use the module.rules configuration with options object.","message":"Options like 'htmlmin' and 'beautify' must be passed via webpack's use.options object, not as query parameters in the inline loader string.","severity":"gotcha","affected_versions":"*"},{"fix":"Consider switching to a more actively maintained EJS loader or using webpack 5's native options handling.","message":"The loader uses loader-utils, which is deprecated in webpack 5. In webpack 5, prefer using the built-in getOptions() from schema-utils.","severity":"deprecated","affected_versions":">=5.0.0"},{"fix":"Use absolute paths or resolve paths with path.resolve in webpack config.","message":"When using inline loader syntax, the loader is applied before the file is resolved. Ensure the path is correct relative to webpack's context.","severity":"gotcha","affected_versions":"*"},{"fix":"Install html-minifier as a project dependency if using htmlmin: true.","message":"The 'htmlmin' option requires html-minifier to be installed. If not, it silently fails or throws an error.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'0.0.2':26 '4':81 '5':83 'ast':72 'beautif':73 'build':16 'compil':9,33,62 'compile-ejs-load':32 'current':24 'depend':22,38,55 'devdepend':53 'download':91 'easier':57 'ej':10,34,41,61 'ejs3':3 'fork':30 'frontend':20 'function':14 'html':43,65,69 'html-minifi':42,68 'instal':58 'javascript':13,97 'js':47,77 'loader':4,7,35,50 'loader-util':49 'may':93 'minif':66 'minifi':44,70 'minor':29 'move':40 'note':84 'option':63,64 'packag':87 'receiv':95 'runtim':21 'support':60 'templat':11 'time':17 'uglifi':46,76 'uglify-j':45,75 'updat':96 'upgrad':37 'util':51 'version':25 'via':67,74 'webpack':2,6,80 'webpack-ejs3-loader':1 'work':78","created_at":"2026-06-04T18:56:35.800826+00:00","updated_at":"2026-06-04T18:56:35.800826+00:00","problems":[{"fix":"Run npm install ejs --save-dev to ensure ejs is available.","cause":"ejs is a dependency but may not be installed if the package is not fully installed or if using a different package manager.","error":"Module not found: Error: Can't resolve 'ejs'"},{"fix":"Update to version 0.0.2 or manually install loader-utils.","cause":"Old versions of webpack-ejs3-loader may not declare loader-utils as a dependency; it was moved to dependencies in 0.0.2.","error":"Module not found: Error: Can't resolve 'loader-utils'"},{"fix":"Validate the JSON or JavaScript object syntax in your webpack configuration.","cause":"Invalid JSON in webpack config options, e.g., extra comma.","error":"SyntaxError: Unexpected token '?' in JSON at position ..."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/t0lkman/webpack-ejs3-loader/","github":"https://github.com/t0lkman/webpack-ejs3-loader/","docs":null,"changelog":null,"pypi":null,"npm":"webpack-ejs3-loader","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}