'how to generate multiple html files with angular-cli builds?
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?
Solution 1:[1]
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:
- https://github.com/angular/angular-cli/issues/3629
- https://github.com/angular/angular-cli/issues/7124
- https://github.com/angular/angular-cli/issues/7309
However you can always customize the default angular cli
webpack config
anyway you want by using eject feature. Check this issue on that matter.
Solution 2:[2]
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
})
]
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | JoSSte |