Here is my scenario:
I want to use ES6/7 in both client(React) and server(Express), plus PostCSS for CSS, so I need webpack + babel.
Several routes render page hosting React Components, some(React Components) trivial, some heavy.
I want to use pug as view engine, put the entire app in one SPA is not an option.
I have the setup working in dev mode (in my pug templates I include bundled assets directly in build dir with script tags, the problem is in production mode, the path to the bundled js file(s) contains hash and is dynamic.
The common practice for this problem seems to be using HtmlWebpackPlugin, which can inject dynamic bundled js path into your template. The problem is, I have many view templates in pug, I can't put an entry for each one of them in webpack.config.js. The option I am exploring is to have webpack generate a 'partial' that only contains assets include tags like and , then I include this 'partial' in my view templates. But HtmlWebpackPlugin does not work with pug. After some digging, I found another webpack plugin people use - pug-loader. but seems like it will just transform pug to plain HTML. which means I cannot include it as a pug file in all my view templates.
This has to be a solved problem but I just can't seem to find the solution.
Thank you in advance!