2017-12-03 92 views
0

我在我的WebPack配置如下定義:HTML-的WebPack模板選項bodyHtmlSnippet不是爲我工作

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>' 
}); 

「選項」 指定值時,這就是所謂的:

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

建立到webpack-dev-server和生產全部完成沒有錯誤,我能夠顯示應用程序。

所有參數都可以正常工作除了,未添加主體代碼片段。

我在做什麼錯?

+0

Patrick Hund - 感謝您的編輯! – JESii

回答

0

原來我在插件的版本5.x; bodyHtmlSnippet是一個非常新的選項,只在6.1行中可用。