{"id":20251596,"url":"https://github.com/jaylanchen/express-template-reload","last_synced_at":"2026-04-15T19:40:24.403Z","repository":{"id":98202493,"uuid":"141012303","full_name":"JaylanChen/express-template-reload","owner":"JaylanChen","description":"Tiny webpack plugin that make express template(like handlebars) support reload page when changed.","archived":false,"fork":false,"pushed_at":"2018-07-17T01:26:45.000Z","size":11,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-01T09:29:07.948Z","etag":null,"topics":["express","handlebars","hbs","hmr-support","reload","template","webpack"],"latest_commit_sha":null,"homepage":"https://github.com/JaylanChen/express-template-reload","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JaylanChen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-15T08:54:28.000Z","updated_at":"2022-02-14T02:44:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"f9dd2e4e-3322-48b5-8ba0-4536d7ae775a","html_url":"https://github.com/JaylanChen/express-template-reload","commit_stats":{"total_commits":10,"total_committers":3,"mean_commits":"3.3333333333333335","dds":0.5,"last_synced_commit":"86e67f92ffa7f33b4f31d092fbd7daf0ed1eeb7a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JaylanChen%2Fexpress-template-reload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JaylanChen%2Fexpress-template-reload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JaylanChen%2Fexpress-template-reload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JaylanChen%2Fexpress-template-reload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JaylanChen","download_url":"https://codeload.github.com/JaylanChen/express-template-reload/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241702387,"owners_count":20005958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["express","handlebars","hbs","hmr-support","reload","template","webpack"],"created_at":"2024-11-14T10:11:06.883Z","updated_at":"2026-04-15T19:40:24.336Z","avatar_url":"https://github.com/JaylanChen.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# express-template-reload\nTiny webpack plugin that make express template(like handlebars) support reload page when changed.\n\nThis loader is automatically added to this code to support reload page when template changed.\n\n## Installation\n```\nnpm install --save-dev express-template-reload\n```\n\nPS: The temeplate should use loader too, such as `raw-loader`,`html-loader` and so on.\n\n\n## Options\n\nYou can pass a hash of configuration options to `express-template-reload`.\nAllowed values are as follows\n\n|Name|Type|Default|Description|\n|:--:|:--:|:-----:|:----------|\n|**[`enable`](#)**|`{Boolean}`|`true`|Enable this loader or disable, production should disable|\n|**[`name`](#)**|`{String}`||The template name, like: index.hbs|\n|**[`jsRootDir`](#)**|`{String}`||The js relative root path relative project root path, like: client/js/|\n|**[`templateRootDir`](#)**|`{String}`||The template relative root path relative project root path, like: client/view/|\n|**[`nameFormat`](#)**|`{Function}`||Allows format template name base on the JS file name|\n|**[`jsHotAccept`](#)**|`{Boolean}`|`true`|If `true` add `module.hot.accept()` to the bottom of modules allows js `hot module replace`|\n|**[`onlyJS`](#)**|`{Boolean}`|`false`|If `true` just add `module.hot.accept()` to the bottom of modules allows js `hot module replace`, and will not support template reload|\n\n## Why use `jsRootDir`, `templateRootDir`\n\nIn a multiple-page web application, a webpack entry file should have a template, so use them to calculate the path of the template relative to js. And determines whether the template file exists, if not, the current file is a not entry file, also nothing will not modify.\n\nIf you have a better way to judge the current JS is not a webpack entry file, please tell me as soon as possible, thank you.\n\n## For example\n\nFile directory structure\n\n```js\n--client\n----js\n------home\n--------index.js\n...\n----view\n------home\n--------index.hbs\n...\n```\n\nAs we konw if you want to support JS hmr, you should add this\n\n```js\n// home/index.js\nif (module.hot) {\n    //js hmr\n    module.hot.accept();\n}\n```\nIf you want to support reload page when template changed.\n\n```js\n// client/js/home/index.js\nif (module.hot) {\n    // template reload\n    require('../../../client/view/home/index.hbs')\n    module.hot.accept('../../../client/view/home/index.hbs', function () {\n        window.location.reload();\n    })\n    //js hmr\n    module.hot.accept();\n}\n```\n\n\nThis loader is automatically added to this code to support reload page when template changed.\n\n\n## Usage\n```js\n// webpack.config.js\n\nvar webpack = require('webpack');\n\nmodule.exports = {\n  entry: [\n    'webpack-hot-middleware/client?reload=true',\n    './entry.js'\n  ],\n  output: {\n    filename: 'bundle.js'\n  },\n  plugins: [\n    new webpack.NoErrorsPlugin()\n  ],\n  module: {\n    rules: [\n      {\n        test: /\\.js$/,\n        exclude: /node_modules/,\n        use:[{\n          loader: 'babel-loader',\n        },{\n          loader: 'express-template-reload',\n          options: {\n            enable: process.env.NODE_ENV === 'local', //default true\n            name: '[name].hbs',\n            jsRootDir: 'client/js/',\n            templateRootDir: 'client/views/',\n            //nameFormat: name =\u003e name.substr(name.indexOf('views/') + 6, name.length),\n            jsHotAccept: true\n          }\n        }],\n      },\n      {\n        test: /\\.hbs$/,\n        use: {\n          loader: 'raw-loader'\n        },\n        exclude: /node_modules/,\n      }\n    ]\n  }\n};\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaylanchen%2Fexpress-template-reload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaylanchen%2Fexpress-template-reload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaylanchen%2Fexpress-template-reload/lists"}