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

gulp-html5packer

v0.1.0

Published

移动H5页面打包工具,可以根据描述将资源打包进html,替换资源为全局资源包CDN地址,减少请求数量

Downloads

5

Readme

gulp-html5packer

移动H5页面打包工具

版权声明:本插件源码fork自filow的gulp_h5packer项目,版权归filow所有,本人修改了少量的bug并发布来便于本团队使用。

为了减少移动端H5页面的请求数量,往往会在发布前将页面依赖的JS, CSS文件嵌入html中,如果一些资源有全局资源包的支持,也会将其替换为CDN地址。

本插件可以根据link, script, img标签中的标记,选择将文件内容嵌入或者替换为CDN地址。

##功能

1.支持img标签内图片转化为BASE64

2.可以将外联js和CSS的压缩并且转换注入到内联标签里面

3.可以支持网络文件的嵌入和BASE64

用法

首先,在待处理的html文件中加入标记。标记共有三种:

内容替换标记

<link rel="stylesheet" type="text/css" href="something.css" data-replace="true">
<script src="something.js" data-replace="true"></script>

这样就会读取资源文件,把内容嵌入在标签的位置。script标签自动会删去src和data-replace属性,并在标签内嵌入内容。link标签会在后面产生一个style节点,并嵌入内容。标签本身会被删除。

目前插件会自动压缩css和js文件,未来可以通过配置文件取消这一功能。

资源URL替换标记

<link rel="stylesheet" type="text/css" href="local/amui.css" data-replace="amui">
<script src="zepto.js" data-replace="static-zepto"></script>

在data-replace中写入"static-全局资源包名称",即可替换为相应的地址。

替换静态资源包需要先写好配置文件,请在初始化参数中传入:

{
  staticUrl: {
    name: 'http://url.to.path'
  }
}

图片Base64转化标记

<img src="fake.png" data-replace="base64">

注意: 目前Base64转码不考虑文件大小因素,请不要在大图片上加这个标记!

引用

设置完HTML后,在gulpfile.js中引用:

var packer = require('gulp-html5packer');
gulp.task('pack', function (){
  
  gulp.src('./build/*/*.html')
    .pipe(packer())
    .pipe(gulp.dest('./pack'));
});