webpack -- plugin插件

mac2022-06-30  28

插件目的在于解决 loader 无法实现的其他事 这里以html-webpack-plugin插件为例,这个是输出html文件的

npm install html-webpack-plugin --save-dev

然后就可以在插件里面配置了

// webpack.config.js plugins: [ new HtmlWebpackPlugin({ title: '练习', // 这个是html页面的title标签内容 template: 'index.html', // 这个是引用的模板文件 filename: 'index.html' // 这个是输出的html文件名称,也可以是个路径文件,这个路径默认是相对于output.path而言的,也就是`/dist` }) ]

具体关于html-webpack-plugin的配置说明和运用后面专门讲 做完这些,就可以运行npm run build 打开dist里面的index.html,直接在浏览器运行,就可以看见内容和样式了html-webpack-plugin配置详情

转载于:https://www.cnblogs.com/zjh-study/p/10845588.html

相关资源:purgecss-webpack-plugin:用于Webpack的Purgecss插件-源码
最新回复(0)