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 🙏

© 2026 – Pkg Stats / Ryan Hefner

skeleton-webpack-plugin

v1.0.11

Published

A webpack plugin to generate skeleton automatically(自动生成骨架屏的webpack插件)

Readme

skeleton-webpack-plugin

该webpack插件主要用于自动化生成页面的骨架屏

如何使用

在使用之前你需要先安装好该插件,通过如下两种方式都可以完成安装

npm i skeleton-webpack-plugin --save-dev

or

yarn add skeleton-webpack-plugin --dev

插件安装完成之后,可以在你开发环境的webpack中进行如下配置

const SkeletonWebpackPlugin = require('skeleton-webpack-plugin')
cosnt HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
  entry: 'index.js',
  mode: 'development',
  output: {
    path: 'dist',
    filename: 'index.bundle.js'
  },
  plugins: [
    new SkeletonWebpackPlugin({
      outDir: __dirname,
      projectDir: __dirname,
      plugins: []
    }),
    new HtmlWebpackPlugin({
      filename: 'index.html',
      inject: true
    })
  ]
}

添加完配置之后当你启动dev server本地预览页面时,可以打开你的控制台输入skeleton,然后按下回车键,如下图所示

此时,skeleton-webpack-plugin将会生成骨架屏页面的html,并输出到你的指定的文件夹下

配置

skeleton-webpack-plugin构造函数接受三个配置项

  • outDir: 骨架屏页面html的输出目录

  • projectDir: 当前工程的根目录

  • plugins: 骨架屏插件数组,非必传。该参数用于接受骨架屏转化插件函数,下文会有详述。

怎样开发骨架屏插件

骨架屏插件是一个函数,如下所示

function exampleSkeletonPlugin (astInfo, route, projectDir) {
astInfo = {
  html: {
      ast: htmlAst,
      stringify: htmlStringify
    },
    css: {
      ast: cssAst,
      stringify: cssStringify
    }
}
route = window.location.pathname
// 你可以在该函数中编写转换逻辑,将骨架屏的html与css转化为不同端的代码,比如微信小程序,react native,weex,快应用等等。
}

astInfo参数主要包含骨架屏html与css的抽象语法树以及将语法树转化为字符串的stringify函数

html抽象语法树的格式如下:

<div class='post post-featured'>
  <p>Himalaya parsed me...</p>
  <!-- ...and I liked it. -->
</div>

[{
  type: 'element',
  tagName: 'div',
  attributes: [{
    key: 'class',
    value: 'post post-featured'
  }],
  children: [{
    type: 'element',
    tagName: 'p',
    attributes: [],
    children: [{
      type: 'text',
      content: 'Himalaya parsed me...'
    }]
  }, {
    type: 'comment',
    content: ' ...and I liked it. '
  }]
}]

css抽象语法树格式如下:

body {
  background: #eee;
  color: #888;
}

{
  "type": "stylesheet",
  "stylesheet": {
    "rules": [
      {
        "type": "rule",
        "selectors": [
          "body"
        ],
        "declarations": [
          {
            "type": "declaration",
            "property": "background",
            "value": "#eee",
            "position": {
              "start": {
                "line": 2,
                "column": 3
              },
              "end": {
                "line": 2,
                "column": 19
              }
            }
          },
          {
            "type": "declaration",
            "property": "color",
            "value": "#888",
            "position": {
              "start": {
                "line": 3,
                "column": 3
              },
              "end": {
                "line": 3,
                "column": 14
              }
            }
          }
        ],
        "position": {
          "start": {
            "line": 1,
            "column": 1
          },
          "end": {
            "line": 4,
            "column": 2
          }
        }
      }
    ]
  }
}