@ysfe/inject-only-html-webpack-plugin
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

@ysfe/inject-only-html-webpack-plugin

webpack plugin: 仿 html-webpack-plugin, 将 js 转化为 <script> 注入到 html 中

前置依赖

  1. webpack >= 5.0.0

使用方式

  1. 安装: yarn add @ysfe/inject-only-html-webpack-plugin --dev

  2. 使用:

    import InjectOnlyHtmlWebpackPlugin from '@ysfe/inject-only-html-webpack-plugin'
    
    // in webpack.config.js
    module.exports = {
      plugins: [
        new InjectOnlyHtmlWebpackPlugin({ /* ... */ })
      ]
    }
    
  3. 参数说明

    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 中.

注意事项


[其他说明事项]

版本说明

Package Sidebar

Install

npm i @ysfe/inject-only-html-webpack-plugin

Weekly Downloads

0

Version

1.2.1

License

MIT

Unpacked Size

26.1 kB

Total Files

17

Last publish

Collaborators

  • wellfee
  • huanyansss