{"id":40746,"library":"compile-ejs-loader","title":"compile-ejs-loader","description":"A webpack loader that precompiles EJS templates into JavaScript functions at build time, removing the need for client-side EJS runtime dependencies. Current stable version 0.0.3, last updated 2018 (maintenance mode). For webpack 5+. Unlike ejs-loader, this loader focuses on compiling templates without shipping the full EJS engine to the browser. Supports HTML minification and beautification via options. Very low maintenance cadence; no updates since 2018.","status":"maintenance","version":"0.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/defims/compile-ejs-loader","tags":["javascript"],"install":[{"cmd":"npm install compile-ejs-loader","lang":"bash","label":"npm"},{"cmd":"yarn add compile-ejs-loader","lang":"bash","label":"yarn"},{"cmd":"pnpm add compile-ejs-loader","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: requires webpack ^5.18.0 to function as a loader.","package":"webpack","optional":false}],"imports":[{"note":"Only CommonJS require works in webpack config. In webpack 5, ESM imports are not supported for inline loader syntax; use `require`. This loader returns a compiled template function.","wrong":"const template = require('compile-ejs-loader!./file.ejs');","symbol":"compile-ejs-loader","correct":"import template from 'compile-ejs-loader!./file.ejs';"},{"note":"Both `loader` and `use` work for single loaders. If using options, wrap with `{ loader: 'compile-ejs-loader', options: {} }`.","wrong":"module.exports = { module: { rules: [ { test: /\\.ejs$/, use: 'compile-ejs-loader' } ] } }","symbol":"compile-ejs-loader (webpack config rule)","correct":"module.exports = { module: { rules: [ { test: /\\.ejs$/, loader: 'compile-ejs-loader' } ] } }"},{"note":"htmlmin option enables minification; additional minifier options must be placed under `htmlminOptions` key.","wrong":"options: { htmlmin: true, removeComments: true }","symbol":"options","correct":"options: { htmlmin: true, htmlminOptions: { removeComments: true } }"}],"quickstart":{"code":"// webpack.config.js\nconst path = require('path');\n\nmodule.exports = {\n  entry: './src/index.js',\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    filename: 'bundle.js'\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.ejs$/,\n        loader: 'compile-ejs-loader',\n        options: {\n          compileDebug: false,\n          beautify: true,\n          htmlmin: true,\n          htmlminOptions: {\n            removeComments: true,\n            collapseWhitespace: true\n          }\n        }\n      }\n    ]\n  }\n};\n\n// src/index.js\nconst template = require('compile-ejs-loader!./template.ejs');\nconst html = template({ name: 'World' });\nconsole.log(html);","lang":"javascript","description":"Shows webpack configuration using compile-ejs-loader with htmlmin, beautify options and inline require usage."},"warnings":[{"fix":"Consider using ejs-compiled-loader or ejs-loader for active maintenance.","message":"Package not updated since 2018; may have compatibility issues with newer webpack or EJS versions.","severity":"deprecated","affected_versions":">=0.0.3"},{"fix":"Use absolute paths or adjust webpack context option for reliable includes.","message":"Child template includes are resolved relative to the webpack execution directory, not the template file.","severity":"gotcha","affected_versions":"*"},{"fix":"Ensure 'filename' is not used in loader options; the loader handles it internally.","message":"Loader options are passed directly to EJS; some EJS options like 'filename' may cause issues if not set correctly.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'0.0.3':31 '2018':34,73 '5':39 'beautif':63 'browser':58 'build':16 'cadenc':69 'client':23 'client-sid':22 'compil':2,48 'compile-ejs-load':1 'current':28 'depend':27 'ej':3,10,25,42,54 'ejs-load':41 'engin':55 'focus':46 'full':53 'function':14 'html':60 'javascript':13,74 'last':32 'loader':4,7,43,45 'low':67 'mainten':35,68 'minif':61 'mode':36 'need':20 'option':65 'precompil':9 'remov':18 'runtim':26 'ship':51 'side':24 'sinc':72 'stabl':29 'support':59 'templat':11,49 'time':17 'unlik':40 'updat':33,71 'version':30 'via':64 'webpack':6,38 'without':50","created_at":"2026-06-04T18:49:03.140495+00:00","updated_at":"2026-06-04T18:49:03.140495+00:00","problems":[{"fix":"Add a rule for .ejs files: { test: /\\.ejs$/, loader: 'compile-ejs-loader' }","cause":"Webpack is treating the .ejs file as raw text instead of using the loader.","error":"Module parse failed: Unexpected token (1:0) in file.ejs"},{"fix":"Run: npm install compile-ejs-loader --save-dev","cause":"Loader not installed or not in node_modules.","error":"Cannot find module 'compile-ejs-loader'"},{"fix":"Add compile-ejs-loader rule in webpack config as shown in quickstart.","cause":"Webpack missing rule for .ejs files.","error":"You may need an appropriate loader to handle this file type."},{"fix":"Use a path relative to the project root or set webpack context to your source directory.","cause":"Includes are resolved from webpack execution directory, not relative to template.","error":"Template include 'templates/child' is not working; file not found."}],"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/defims/compile-ejs-loader","github":"https://github.com/defims/compile-ejs-loader","docs":null,"changelog":null,"pypi":null,"npm":"compile-ejs-loader","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"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}}