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

@web-pro/html-extend-webpack-plugin

v1.0.1

Published

a html-webpack-plugin extension

Downloads

10

Readme

html-extend-webpack-plugin

一个html-webpack-plugin扩展插件,该插件依赖于 [email protected] 插件

仓库

安装

使用npm安装

npm i @web-pro/html-extend-webpack-plugin -D

使用yarn安装

yarn add @web-pro/html-extend-webpack-plugin -D

作用

该插件的作用是在webpack中我们使用html-webpack-plugin插件生成 html模板文件时,向生成的模板(html)中插入第三方cdn形式的jscss

使用

webpackplugin 中进行配置,

const HtmlExtendWebpackPlugin = require("@web-pro/html-extend-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin")

module.exports = {
  plugin:[
    new HtmlExtendWebpackPlugin(HtmlWebpackPlugin,options),
  ]
}
  • 第一个参数HtmlWebpackPluginhtml-webpack-plugin插件对象

  • 第二个参数options为配置对象:

{
  addJs:Array || Function,
  addCss:Array || Function,
}
  1. 字段addJs添加引入js的地址(如CDN),值可以为数组或函数,
  • 当为数组Array时,默认情况下打包时会将数组中的js地址依次插入到html模板中,位置处于打包出的<script></script>标签最前面;

  • 当为函数Function时,函数的第一参数为一个数组,里边存储着打包时,引入的js链接地址,你可以将要添加的CDN插入到数组中某个位置,并返回一个新数组,这样打包出html模板中,引入的script顺序会按照你返回的数组中的顺序引入

  1. 字段addCss字段同上,只不过是对css进行处理

例子

const HtmlExtendWebpackPlugin = require("@web-pro/html-extend-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin")

module.exports = {
  plugin:[
    new HtmlExtendWebpackPlugin(HtmlWebpackPlugin,{
      // 数组形式添加js
      addJs:["https://cdn.bootcss.com/vue/2.6.10/vue.common.js"], 


      // 函数形式添加js
      addJs:function(jsList){
        return jsList.push("https://cdn.bootcss.com/vue/2.6.10/vue.common.js")
      }, 

      // 数组形式添加css
      addCss:["https://cdn.bootcss.com/twitter-bootstrap/4.3.1/css/bootstrap-grid.css"], 


      // 函数形式添加css
      addCss:function(cssList){
        return cssList.push("https://cdn.bootcss.com/twitter-bootstrap/4.3.1/css/bootstrap-grid.css")
      }, 
    }),
  ]
}