Webpack:如何将 javascript 注入 HTML 而不是单独的 JS 文件

Webpack: How to inject javascript into the HTML instead of separate JS file

有没有办法让 webpack 将输出注入 HTML 而不是单独的文件?

<html>
  <head>
  </head>
  <body>
    <script type="text/javascript">
      // webpack puts the output here
    </script>
  </body>
</html>

我不得不使用 html-webpack-inline-source-pluginhttps://github.com/DustinJackson/html-webpack-inline-source-plugin

plugins: [
  new HtmlWebpackPlugin({
    inlineSource: '.(js|css)$' // embed all javascript and css inline
  }),
  new HtmlWebpackInlineSourcePlugin()
]