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

sp-merge-in-html

v1.1.1

Published

合并 html 引用到的组件化 css,js。

Downloads

2

Readme

说明

合并 html 引用到的组件化 css,js。

使用

"sp-merge-in-html":{
  "css": {
    "selector": ["link[component]"],
    "search":["less"],
    "out": "css/$file.css",
    "appendTo": "head"

  },
  "js": {
    "selector": ["script[component]"],
    "search":[],
    "out": "js/$file.js",
    "appendTo": "head"
  },
  "script": false //or true,
  "stype":  false // or true
}

options css

css 用来配置 link 组件。如有index.html如下:

<html>
  <head>
    ...
    <link rel="stylesheet" href="/css/A.css" type="text/css">
    <link rel="stylesheet" href="/css/component-A.css" type="text/css" component>
  </head>
  <body>
  ...
    <link rel="stylesheet" href="/css/component-B.css" type="text/css" component>
  </body>
<html>

css.selector 可选 默认值:["link[component]"]

Array , 元素选择器,用来告诉插件哪些是你的自定义组件。 默认值:["link[component]"].

插件会在页面里面找到所有的 $(css.selector) 把它们标记为组件。等待下一步处理。

css.search 可选,默认值:[]

插件提取 $(css.selector)href的值,在项目目录下进行搜索匹配。 默认搜索href本身表示的文件链接,如/css/component-A.css。 如果找到, 那么就会把文件内容,写入到css.out配置的文件中。 如果没有找到,那么会依次用css.search的元素 替换 该href.css后缀,直到找到为止。 如果搜索完 全部后缀依然没有找到,那么抛出异常。

css.out 可选, 默认:"/css/$file.css"

输出文件路径。 其中 $file 为变量, 会把 该link所在的html名字替换它。

css.appendTo 可选 默认 "head"

合并后到文件添加到那个标签末尾。

如上述例子所示,那么结果为:

<html>
  <head>
    ...
    <link rel="stylesheet" href="/css/A.css" type="text/css">
    <link rel="stylesheet" href="/css/index.css" type="text/css">
  </head>
  <body>
  ...
  </body>
<html>

options js

配置同 css

options script

合并 script标签内的文本 插入到body后

options style

合并 style 标签内的文笔,插入到head后