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 🙏

© 2025 – Pkg Stats / Ryan Hefner

grunt-ne

v0.1.0

Published

Grunt plugins including css-collect, spm-build and html-replace

Readme

grunt-ne

三个grunt插件的集合,打包前端资源

开始使用

安装

npm install grunt-ne

配置

添加下面一行到你的grunt.js

grunt.loadNpmTasks('grunt-ne');

然后为插件增加像下面这样的配置:

grunt.initConfig({
  ...
  pkg: {
    name: "jy",
    dist: "dist",
    base_uri: "http://static.mail.com/jy"
  },

  css_version: {
    main: {
      css_src: "./css",
      css_dst: "css",
      img_dst: "img",
      resource_map_file: "<%= pkg.dist %>/css-resource-map.json"
      files: "**/*.css"
    }
  },

  spm: {
    root: "./js",
    resource_map_file: "<%= pkg.dist %>/js-resource-map.json",
    options: {
      src: ".",
      dist: "../<%= pkg.dist %>/js"
    }
  },

  html_substitute: {
    main: {
      resource_map: ["<config:css_version.main.options.resource_map_file>"],
      src: "./html",
      files: "*.html"
    }
  },
  ...
});

命令

css_version

读取css_src中的css文件,分析css文件中的图片引用,把这些图片保持原有目录地移到img_dst,并把对图片做md5处理后的值作为该图片文件名一部分,css文件中对该图片的引用路径也更改为图片处理后的路径;移动css文件到css_dst,对css文件压缩并做把md5处理后的值作为该css文件名一部分,最后产出resource_map_file

spm

对使用 seajs 组织的模块使用 spm 打包,最后产出resource_map_file,上线后调用seajs.map(%resource_map%);resource_map_file的内容替换%resource_map%,就能无缝地去加载打包后的资源文件。

html_substitute

根据resource_map,对模版文件的资源引用的路径替换,暂时只能识别css引用。