html-webpack-template option bodyHtmlSnippet not working for me

186 Views Asked by At

I have the following definition in my webpack config:

new HtmlWebpackPlugin({
    inject: false,
    template: require('html-webpack-template'),
    links: [{
        rel: 'stylesheet',
        href: 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css',
        integrity: 'sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u',
        crossorigin: 'anonymous'
    }, {
        rel: 'stylesheet',
        href: 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css',
        integrity: 'sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp',
        crossorigin: 'anonymous'
    }, {
        rel: 'stylesheet',
        href: 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css',
        crosorigin: 'anonymous'
    }, { rel: 'icon', type: 'image/png', sizes: '32x32', href: '/favicon-32x32.png' }],
    scripts: [{
        src: 'https://code.jquery.com/jquery-3.2.1.min.js',
        integrity: 'sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=',
        crossorigin: 'anonymous'
    }, {
        src: 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js',
        integrity: 'sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa',
        crossorigin: 'anonymous'
    }],
    title: options.title,
    appMountId: options.appMountId,
    bodyHtmlSnippet: '<div id=\'demo\'></div>'
});

The "options" values are specified when this is called:

parts.indexTemplate({
    title: 'Free Code Camp Exercises',
    appMountId: 'app'
})

Builds to webpack-dev-server and production all complete with no errors and I am able to display the app.

All parameters work just fine except, the body-snippet is not added.

What am I doing wrong?

1

There are 1 best solutions below

0
On

Turns out I was on version 5.x of the plugin; bodyHtmlSnippet is a very new option and only available in the 6.1 line.