6

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 Answer 1

4

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()
] 
Sign up to request clarification or add additional context in comments.

4 Comments

Works! But with version 4.39 of webpack it was initially throwing an error. It was solved by using the beta version: [email protected] and using it with: new HtmlWebpackInlineSourcePlugin(HtmlWebpackPlugin).
Does not work anymore
@Dr.Random which version of webpack, node and the plugins are you using?
I installed all the latest a couple of days ago.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.