简体   繁体   中英

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

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>

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()
] 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM