webdiscus / html-bundler-webpack-plugin

Alternative to html-webpack-plugin ✅ Renders Eta, EJS, Handlebars, Nunjucks, Pug, Twig templates "out of the box" ✅ Resolves source files of scripts, styles, images in HTML ✅ Uses a template as entry point
ISC License
138 stars 14 forks source link

[FEATURE REQUEST] Watch handlebars helpers for changes #25

Closed 5ulo closed 1 year ago

5ulo commented 1 year ago

Current behaviour

Changes made to handlebars helper *.js are not compiled. Page reloads on helper save, but the changes are not compmilet back to the output. As for now the solution is to restart npm run start. Also adding/renaming/deleting helper file does not made any changes.

Expected behaviour

Changes should be compiled to the code.

Reproduction Example

loaderOptions: {
    preprocessor: 'handlebars',
    preprocessorOptions: {
        root: path.join(PATH_PAGES),
        views: [
            PATH_PARTIALS
        ],
        partials: [
            PATH_PARTIALS
        ],
        helpers: [
            PATH_HELPERS
        ]
    },
},

helpers are in project root helpers/*.js

Environment

Additional context

Thank you

webdiscus commented 1 year ago

Hello @5ulo,

thanks for this feature request. It can be really useful. This feature is not trivial, so it may take some time to implement.

webdiscus commented 1 year ago

@5ulo try the new version 2.8.0. You can add/remove/rename/change a helper in the helper's directory.

One limitation: by add/remove/rename of a helper file, the template will be new compiled, but the browser will not be live reloaded.

This seems to be a bug in the Webpack HMR code, because the hot update code says in the browser console:

[HMR] Checking for updates on the server... [log.js:39:12](webpack:///node_modules/webpack/hot/log.js?)
[HMR] Nothing hot updated. [log.js:39:12](webpack:///node_modules/webpack/hot/log.js?)
[HMR] App is up to date.

You should reload your browser manually. I don'k know how to fix it :-/

5ulo commented 1 year ago

Manual reload on create/remove/rename is the least.. HMR on content change works with the 2.8.0. Good job