简体   繁体   中英

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.

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

you can use code block.

<code>js code here</code>

It is non executable code.

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