npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

webpack-plugin-addscriptforhtmlplugin

v1.0.5

Published

webpack plugin addscriptforhtmlplugin

Downloads

220

Readme

addScriptForHtmlPlugin

  1. 根据参数 isInsertBody 决定插入到 head 还是 body 里面
  2. 在 head | body 里面根据参数 isShift 决定是 前置插入还是后置插入
  3. inject: false,只会插入在body 里面,但是可以根据参数 isShift 决定是 在body进行 前置插入还是 后置插入
  4. 可以通过设置 jsDeferLoad | jsAsyncLoad 来决定 标签的 defer 和 async 属性
  5. url 和 innerHTML 不可以同时设置,也不可以同时不设置 (两者总要设置一个)
  6. needScriptTemplate: false 表示不需要插件提供任何 tempalte 代码,直接把 开发者提供的代码 插入进来

Usage

使用参考 该插件功能和 webpack-plugin-forceinsertscripttag 一致 (https://juejin.cn/post/7382891667672121394)

webpack-plugin-forceinsertscripttag 功能实现依赖 html-webpack-plugin, 此插件不依赖外部插件,直接可以使用

const AddScriptForHtmlPlugin = require('webpack-plugin-addscriptforhtmlplugin');

module.exports = {
    ...
    plugins: [
        ...
        new AddScriptForHtmlPlugin({
            isShift: true, // default: true 前置插入 还是 后置插入
            isInsertBody: true, //default: true  插入的 head 里面 还是 body 里面 (html-webpack-plugin 的 inject: false,只会插入在body 里面)
            url: 'xxx.js', // 被加载的 js 地址
            jsDeferLoad: false, // default: false  插入的 js 需不需要 在<script> 设置 defer 属性
            jsAsyncLoad: false, // default: false  插入的 js 需不需要 在<script> 设置 async 属性
            innerHTML: 'xx',
        }),
    ]
}