做推广优化的网站有哪些,推广型网站建设网址,网站备案格式,网站建设实训小结我们使用html-webpack-plugin插件可以自动在打包代码目录生成html文件
使用步骤#xff1a;
一、安装依赖
在控制台中输入如下代码#xff1a; npm i -D html-webpack-plugin 二、在webpack.config.js中配置插件
const HTMLPlugin require(html-webpack-plugin
一、安装依赖
在控制台中输入如下代码 npm i -D html-webpack-plugin 二、在webpack.config.js中配置插件
const HTMLPlugin require(html-webpack-plugin);
module.exports {mode: production, // 设置打包的模式production生产模式 development开发模式plugins:[new HTMLPlugin()]
} 三、打包文件 在控制台中输入npx webpack进行项目打包打包目录下就自动生成了index.html文件 四、根据模板在打包目录下生成html文件 如果我们想要生成的html文件和src文件下的html文件中的一致我们可以在创建HTMLPlugin实例对象的时候传入参数。 const HTMLPlugin require(html-webpack-plugin);
module.exports {mode: production, // 设置打包的模式production生产模式 development开发模式plugins: [new HTMLPlugin({template:./src/index.html // 设置模板为src文件下的index.html文件})]
}