问题
Is there a way to have webpack inject the output into the HTML instead of a separate file?
<html>
<head>
</head>
<body>
<script type="text/javascript">
// webpack puts the output here
</script>
</body>
</html>
回答1:
I had to use the html-webpack-inline-source-plugin
. https://github.com/DustinJackson/html-webpack-inline-source-plugin
plugins: [
new HtmlWebpackPlugin({
inlineSource: '.(js|css)$' // embed all javascript and css inline
}),
new HtmlWebpackInlineSourcePlugin()
]
来源:https://stackoverflow.com/questions/52846031/webpack-how-to-inject-javascript-into-the-html-instead-of-separate-js-file