Skip to content Skip to sidebar Skip to footer

Make Webpack Render In A File Other Than An Index

By default Webpack looks for a specific index.html file in a specified directory, right? What I want to know is can I tell webpack to look for and inject my bundled files in a file

Solution 1:

Easiest way: you can configure webpack to use any file and template file via the html-webpack-plugin plugin. You can also specify the element to inject into.

import HtmlWebpackPlugin from 'html-webpack-plugin';
[...]
  const plugins = [
    new HtmlWebpackPlugin({
      template: 'templates/myTemplateFile.tpl.html',
      inject: 'body',
      filename: 'myOutputFile.html'
    })
  ];

Post a Comment for "Make Webpack Render In A File Other Than An Index"