How to use html-webpack-plugin with existing express templates?

I included the express-genereton npm module and wanted how the project is structured using jade files used as templates. However, I also like to use the HTML-webpack-plugin, which generates its own files, which is best suited for integrating both approaches?

+4
source share
1 answer
  • Step 1:

Create html file (s):

module.exports = {
  entry: {
    'page1': './apps/page1/scripts/main.js',
    'page2': './apps/page2/src/main.js'
  },
  output: {
    path: __dirname,
    filename: "apps/[name]/build/bundle.js"
  },
  plugins: [
    new HtmlWebpackPlugin({
      inject: true,
      chunks: ['page1'],
      filename: 'apps/page1/build/index.html'
    }),
    new HtmlWebpackPlugin({
      inject: true,
      chunks: ['page2'],
      filename: 'apps/page2/build/index.html'
    })
  ]
};
  • Step 2: add the generated html file to your jade file

    enable ../../ public / index.html

0
source

Source: https://habr.com/ru/post/1654636/


All Articles