Webpack系列——Plugin的使用
作者:互联网
plugin的使用
plugin 可以在 webpack 运行到某个时刻的时候,帮助实现一些事情。
htmlWebpackPlugin
会在打包结束后自动生成一个html文件,并把打包生成的js自动引入到这个html文件中。
插件安装:
npm install --save-dev html-webpack-plugin
webpack.config.js配置
在plugins选项数组中添加插件
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
// ...
plugins: [
new HtmlWebpackPlugin({
template: "./src/index.html", // 这里设置自己模板文件
}),
// 或者不设置模板
// new HtmlWebpackPlugin()
],
};
标签:插件,系列,plugin,Plugin,webpack,Webpack,html,HtmlWebpackPlugin,plugins 来源: https://blog.csdn.net/Smart_J_King/article/details/122454529