@ysfe/inject-only-html-webpack-plugin
webpack plugin: 仿 html-webpack-plugin, 将 js 转化为 <script> 注入到 html 中
前置依赖
- webpack >= 5.0.0
使用方式
-
安装:
yarn add @ysfe/inject-only-html-webpack-plugin --dev
-
使用:
import InjectOnlyHtmlWebpackPlugin from '@ysfe/inject-only-html-webpack-plugin' // in webpack.config.js module.exports = { plugins: [ new InjectOnlyHtmlWebpackPlugin({ /* ... */ }) ] }
-
参数说明
uglify 参考: html-minifier-terser
参数 类型 描述 可选 output string 输出文件名 ✅ template string html 模板路径 or html 模板内容 ✅ chunks string / Array 需要加载哪些入口 ✅ scriptTag {charset?:string; defer?:boolean} 自定义 script 属性 ✅
实现方案
- 参考 html-webpack-plugin 实现, 将 js 打包到 html 中.
注意事项
[其他说明事项]