bdddd
bdddd

Reputation: 103

How to copy js to html file with webpack?

I want to render html file with css, fonts and js inside (not linked but content inside). Css and fonts I have, but I can't find solution for js. I work on Node.js.

Upvotes: 1

Views: 1222

Answers (2)

Ivan Drinchev
Ivan Drinchev

Reputation: 19581

You can use a plugin like html-webpack-inline-source-plugin.

Add to the plugins object in your webpack.config.js file

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

NB : This plugin only works together with html-webpack-plugin

Upvotes: 2

rakesh shrestha
rakesh shrestha

Reputation: 1435

you can use code block.

<code>js code here</code>

It is non executable code.

Upvotes: 0

Related Questions