how to generate multiple html files with angular-cli builds?

4.2k views Asked by At

I have an angular project with manual setup (no angular-cli) and configured the build to generate multiple html files using HTML Webpack Plugin. Now, I am planning to move to angular-cli and wondering how can i generate multiple html files along with index.html?

2

There are 2 answers

0
angularconsulting.au On

I do not quite understand the purpose of you having multiple html files.

You might need to check this angular cli issue: Support for multiple html pages. But in case if you want to setup angular cli to be able produce multiple apps, then check this issues:

However you can always customize the default angular cli webpack config anyway you want by using eject feature. Check this issue on that matter.

0
mirik On

You can use custom-webpack with plugins:

  • angular.json
"options": {
   "customWebpackConfig": {
      "path": "./custom-webpack.config.js"
   }
}
  • custom-webpack.config.js
import HtmlWebpackPlugin from 'html-webpack-plugin';
export default env => {
 ...
 return {
  ...
  "plugins": [
   new HtmlWebpackPlugin({
     template: 'index.html',
     minify: true
   })
  ]
 }
}