要解决“Angular 6. Html Webpack Pluggin问题”,你可以按照以下步骤进行操作:
确保你已经安装了html-webpack-plugin插件。可以通过运行以下命令进行安装:
npm install --save-dev html-webpack-plugin
打开angular.json文件,并找到architect下的build配置项。在options对象中添加一个新的属性index,并将其值设置为src/index.html:
"architect": {
"build": {
"options": {
"index": "src/index.html",
...
},
...
},
...
}
打开webpack.config.js文件,并在顶部添加以下代码:
const HtmlWebpackPlugin = require('html-webpack-plugin');
在module.exports对象中的plugins数组中添加以下代码:
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html',
filename: './index.html'
}),
...
]
这将告诉Webpack将src/index.html作为模板文件,并将生成的文件命名为index.html。
保存文件并重新启动Webpack编译。这通常可以通过运行以下命令来实现:
npm start
这样,你就可以解决“Angular 6. Html Webpack Pluggin问题”。