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

generator-mod-browserify

v0.5.1

Published

Create a webapp with mod.js and browserify

Downloads

4

Readme

generator-mod-browserify

yo

基于 mod.jsbrowserify 的Yeoman生成器。

准备

你需要事先了解这几样东西

  1. Yeoman
  2. CommonJs
  3. browserify
  4. generator-webapp

项目基于generator-webapp做了很多扩展。

简单介绍下browserify:

将符合CommonJs规范的js代码生成浏览器可以直接执行的js代码。

比如:

// a.js
module.exports = "this is a.js"
// b.js
var a = require(./a.js);
console.log(a); // "this is a.js"

通过browserify,会将a.jsb.js合并成浏览器执行的js代码。

安装

安装Yo

你需要安装Yo,具体安装方法可以看看这里

安装Generator
npm install generator-mod-browserify -g

使用

Yo一下
yo mod-browserify
目录结构
app
 |-- components bower或者components外部依赖
 |-- images
 |-- styles
   |-- app.scss 主入口css文件
 |-- scripts
   |-- app.js 主入口js文件
   |-- imports 待导入到app.js的所有js文件
   |-- modules 本地模块
tasks grunt拆分任务目录

说明

app/components

使用bower或者component安装的目录,不一定都是符合CommonJs规范。

建议对于外部依赖提供的方法,都写在app/scripts/imports/define.js里:

var $ = window("$");
var Broadcast = require("binnng/broadcast");
注意

这里的require是mod.js(app/components/mod.js/mod.js)提供的方法,便于引入app/components里符合CommonJs规范的js文件,这也是我引入mod.js的主要原因。

当然,如果符合CommonJs规范,你也可以写在app/scripts/modules里:

var domify = require("../components/domify/domify.js");

如果多个模块都要使用domify这个方法,那就得在modules文件里写很多遍上面的代码,所以还是建议写在app/scripts/imports/define.js

var domify = require("domify");

modules里直接使用domify这个方法就行。

tasks

这是拆分了的grunt任务目录

具体可以看看我这个项目:grunt-task-module

主要作用是:

拆分grunt任务,免得gruntfile.js越来越长,越来越难以维护。

功能

除了基本的generator-webapp提供的grunt服务,还做了些扩展。

grunt publish

发布 build后如果要做些特殊处理,可以写在tasks/publish.js里。

grunt doc

生成js(Coffee)文档。 可以看看docco

grunt serve:doc

访问文档。