colbyfayock / html-webpack-partials-plugin

🛠 Easy HTML partials for Webpack without a custom index!
MIT License
68 stars 20 forks source link

Add more targetfile options #16

Closed bluebrown closed 4 years ago

bluebrown commented 4 years ago

Hi,

I think it would be good to be able to specify the name of the output file from HTML plugin instead of the name of the template. This is useful when using the same template but injecting different chunks.

 entry: {
    index: './src/',
    other: './src/other',
  },
  plugins: [
    new HtmlWebpackPlugin({
      title: 'Home',
      template: './src/baseof.html',
      filename: 'index.html',
      chunks: ['index'],
    }),
    new HtmlWebpackPlugin({
      title: 'Other',
      template: './src/baseof.html',
      filename: 'other.html',
      chunks: [other'],
    }),
    new HtmlWebpackPartialsPlugin([
      {
        path: path.join(__dirname, './src/index_partial.html'),
        priority: 'high',
        location: 'main',
        // template filename is not useful in this scenario
        template_filename: 'index.html'
      },
      {
        path: path.join(__dirname, './src/other_partial.html'),
        priority: 'high',
        location: 'main',
        // using the name of the output file would be better
        output_filename: 'other.html'
      }
    ]),
  ],
bluebrown commented 4 years ago

Never mind, it works just like that.