Answer the question
In order to leave comments, you need to log in
Webpack does not add hbs code to compiled html file, what should I do?
webpack:
module.exports = {
//......
plugins: [
new HTMLWebpackPlugin({
hash: false,
inject: false,
template: './src/views/index.hbs',
minify: {
collapseWhitespace: isProd
},
})
],
module: {
rules: [
{
test: /\.hbs$/,
use: ['handlebars-template-loader']
}
],
},
};
//....
const app = express();
const hbs = exphbs.create({
defaultLayout: 'main',
extname: 'hbs'
});
app.engine('hbs', hbs.engine);
app.set('view engine', 'hbs');
app.set('views', './src/views');
app.use(express.static(path.join(__dirname + '/dist/')));
app.use('/', homeRoute);
//....
{{> head }}
<body>
{{> header }}
{{> up }}
{{> preolaider }}
{{{ body }}}
{{> footer }}
{{> down }}
</body>
</html>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question