sagold / handlebars-webpack-plugin

Renders your html-template at build time
162 stars 45 forks source link

Watching nested partials #65

Closed maratfakhreev closed 3 years ago

maratfakhreev commented 4 years ago

Hi @sagold, I'm really sorry for this terrible delay from my side. For some time I've left project where I used this package but I've found the time to take a look how it looks with the changes. Related to our last https://github.com/sagold/handlebars-webpack-plugin/pull/56 I like the idea to use '[path]' for getting relative paths, but unfortunately two problems I've found. First of all, here is my config for now:

new HandlebarsPlugin({
        entry: path.resolve(appDir, 'views', '**', '*.hbs'),
        output: path.resolve(buildDir, '[path]', '[name].html'),
        partials: [
          path.resolve(appDir, 'views', 'components', '**', '*.hbs'),
        ],
        data: {
          appVersion,
          dev: NODE_ENV === 'development',
        },
}),

1) If I've partials inside my views directory, like in my case it is views/components they're going to be ignored through the compile process. I see that such issues has already is https://github.com/sagold/handlebars-webpack-plugin/issues/64. Removing the code in your branch doesn't solve the problem and is starting to send message Error: The partial @partial-block could not be found. To be honest It is not a big deal and it fixes if you separate partials path and views. But anyway issue is here.

2) The next and probably more advantage problem (and if I'm not mistaken it was in my PR) that webpack watcher doesn't handle new .hbs files. So every time you should restart server or make some change in existing file to handle new ones.

So what do you think about it? And thank you for your work!)

sagold commented 4 years ago

Would you mind upgrading to html-webpack-plugin@v2.1.1? Here, helpers and partials are resolved each compilation (change while serving) and reload any referenced partials (new and old). In may test case, this works as expected and should resolve at least your issue 2.

As for issue 1. I am interested to here from any changed behaviour.

Thanks, sagold

maratfakhreev commented 4 years ago

Thank you! Сheck it out soon