最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin4浏览0评论

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>

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>
Share Improve this question asked Oct 17, 2018 at 1:20 Stephen GilboyStephen Gilboy 5,8352 gold badges33 silver badges41 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

I had to use the html-webpack-inline-source-plugin. https://github./DustinJackson/html-webpack-inline-source-plugin

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

评论列表(0)

  1. 暂无评论