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

fis-postpackager-widgetinhtml

v0.0.3

Published

inline widget

Downloads

29

Readme

html 片段和对应的 css 放在一起管理

需求背景

html 片段放在 html 文件中,对应的样式放在 css 文件中,产品需求变更或视觉调整需要删掉某一块时,开发 GG 通常都只删除了响应的 html 片段,他们才不会去 css 文件中找到对于那个的样式,把它干掉呢! 这样就存在了无用的样式,归根结底的原因是:你能把 html 和 css 放在一起么,一个 delete 键解决所有烦恼

===

问题重点

  1. html 的引入,fis 已经有现成的方案,直接 link 一下就可以了。

    <link rel="import" src="modules/test/widget/index.html?__inline" >

  2. 重点是如何解决 css 样式的引入问题。

===

解决方案

  1. 在引入的模块中,通过 link inline到页面中,然后使用 fis 插件将 inline 的样式文件提取到 head 头里面。 这里有2中接入方式:

    <link rel="stylesheet" type="text/css" href="header.css">

    <link rel="stylesheet" type="text/css" href="header.css?__inline">

    第一种方式,总是会以 link 的方式引入 css,第二种方式总是会以 inline 的方式引入,实际的需求希望在 dev 时以 link 方式引入,这样方便定位文件,在 dist 时候以 inline 方式引入。

  2. 使用注释的命令字引入样式,在 postpackage 中读取对应的文件进行处理,这里既可以读取源文件将样式直接插入到 html 中,又可以通过 map 获取对应的 cdn 路径,以 link 方式引入。

    <!-- require(modules/test/widget/index.scss) -->
    <link rel="import" src="modules/test/widget/index.html?__inline" >
       
  3. 使用特殊标签引入所需的html片段, 在 postpackage 中解析标签,替换成对应的 html 代码,并且读取同级路径下,同名的 css 文件引入。

    <widget src="modules/test/widget/index.html">