sagold / handlebars-webpack-plugin

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

Support for multiple pages #9

Closed jshjohnson closed 7 years ago

jshjohnson commented 7 years ago

Hi,

Does this plugin support multiple pages? For example, the entry point would be a glob of Handlebar files and the output would be the directory for each of those compiled pages to go into?

Similar to how Assemble works.

Thanks

sagold commented 7 years ago

Hi jshjohnson.

Unfortunately, this plugin only accepts a single page as start file. You can still build multiple files via the environment variable, something like entry: process.env.page === 1 ? first.js : last.js or use multiple webpack configs (gag).

A more appropriate solution would be a handlebars-loader, which is currently not open source. I will add a note here as soon as its available.

Dinistro commented 7 years ago

@sagold isn't this opensource: https://github.com/altano/handlebars-loader?

sagold commented 7 years ago

@Dinistro The handlebars-loader https://github.com/altano/handlebars-loader does return a template string to perform rendering on the client-side. But this plugin creates the final html on server-side.

@jshjohnson At Süddeutsche Zeitung we rewrote the plugin as a loader, to support multiple handlebars-files which is now available here https://github.com/sueddeutsche/handlebars-render-loader.

Regards.

patrikniebur commented 7 years ago

This is something I needed too and solved in my pull request here https://github.com/sagold/handlebars-webpack-plugin/pull/13

sagold commented 7 years ago

I merged the pr and released the plugin with version v0.2.0