1. HTMLwebpackPlugin插件
HTMLwebpackPlugin会在打包结束后,自动生成一个html文件,并把打包的js自动引入到这个html文件中。
- 在终端上输入npm run bundle ,打包生成后的
- 在index.html 中html中没有这个root的div。
-
在webpack.config.js 中设置模板,这样重新打包时就会自动引入< div id = "root">
plugins:[ new HtmlWebpackPlugin({ template:'src/index.html' }) ],- plugin 可以在webpack运行到某个时刻的时候,帮你做一些事情。
2. clean-webpack-plugin 打包时可以把原来的dist给删除,
- 首先要下载如图的命令,
- 在webpack.config.js中引入
3. entry与output
- 如果要打包出显示两个js文件,需在entry里进行设置,