ericf / express-handlebars

A Handlebars view engine for Express which doesn't suck.
BSD 3-Clause "New" or "Revised" License
2.31k stars 384 forks source link

exphbs + webpack bundling #265

Open borispov opened 4 years ago

borispov commented 4 years ago

Hello,

I am using express-handlebars in my express project and I'm trying to figure out how to bundle correctly with Webpack with the goal of maintaining the benefits of server side rendering.

If you could add such example to your examples dir that would much appreciated. However, an explanation will suffice.

Webpack outputs a single bundled js file, and running it express cannot render the 'hbs' templates because it still looks for them in a folder say "public/views", is it possible that everything will live in this bundled js file ?

Currently my workaround is: copy my public folder to dist/ folder, I don't think this is the best approach though.

Thanks.

UziTech commented 4 years ago

There are two ways I can think of doing it. Copy the public folder into dist (which you are doing) or change your path to the view to be from the dist folder (e.g. ./public/views -> ../public/views)