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

spm-chaos-build

v0.2.5

Published

Build Sea.js Business Modules by Chaos's way.

Downloads

16

Readme

spm-chaos-build

Build Sea.js Business Modules by Chaos's way.


Getting Started

这是一个 Spm2 的插件,使用一种自定义的方式来打包 (build) 业务模块(不是标准模块哦)

打包的方式请参见如何使用 Spm2 压缩合并业务模块

一个简单的例子参见这里 https://github.com/edokeh/spm-chaos-build-example

Install

请先确保你已经安装了最新的 Node.js

$ npm install spm -g
$ npm install spm-chaos-build -g

Usage

$ spm chaos-build [dir] [options]

Options

  • -C 指定 Sea.js 的配置文件,build 完成后会将 MD5 的 MAP 规则写入这个文件
  • -O 指定 build 的输出目录,这个目录应该是 Sea.js 的标准模块目录,里面应该包含业务代码所依赖的标准模块(如 jQuery),可省略此参数,缺省为 sea-modules 目录
  • --gzip 是否压缩输出目录下所有的文件,参数接受 all/current ,分别表示压缩输出目录下所有文件或只压缩此次生成的文件

Example

$ spm chaos-build example -C seajs-config.js
$ spm chaos-build example -C seajs-config.js --gzip current
$ spm chaos-build example -C seajs-config.js -O ../modules
$ spm chaos-build example -C seajs-config.js -O libs --gzip all

自定义任务

与 spm build 一样,支持通过目录下的 Gruntfile.js 来自定义任务,示例代码如下

var chaosBuild = require('spm-chaos-build');

module.exports = function (grunt) {
    chaosBuild.loadTasks(grunt);

    var config = chaosBuild.getConfig('javascripts', {
        outputDirectory : 'javascripts/sea-modules',
        gzip : 'all'
    });
    grunt.initConfig(config);

    grunt.registerTask('write-manifest', function () {
        var mapArr = grunt.config.get('md5map');
        var family = config.family;
        grunt.file.write('seajs-map.json', JSON.stringify(mapArr, null, '\t'));
    });

    grunt.registerTask('chaos-build', [
        'clean:dist', // delete dist direcotry first
        'transport:spm',  // src/* -> .build/src/*
        'concat:relative',  // .build/src/* -> .build/dist/*.js
        'concat:all',
        'uglify:js',  // .build/dist/*.js -> .build/dist/*.js
        'md5:js', // .build/dist/*.js -> dist/*-md5.js
        'clean:spm',
        'spm-newline',
        'compress',
        'write-manifest'
    ]);
};

从 0.2.4 开始支持更细粒度的 concat 配置,如

var config = chaosBuild.getConfig('javascripts', {
    outputDirectory : 'javascripts/sea-modules',
    gzip : 'all'
});
config.concat.relative = [
  "test/a.js",
  {"test/b.js": ["test/b.js", "template/*.html.js"]},
  "test/c.js"
];

History

0.2.5

Fix bug

0.2.4

  • 支持更细粒度的 concat 规则配置
  • 将依赖的 grunt-cmd-transport, grunt-cmd-concat 更新至最新版本

0.2.3

  • 将依赖的 grunt-cmd-transport, grunt-cmd-concat 更新至最新版本
  • 默认支持对 handlebars 后缀文件的打包支持,规则同 grunt-cmd-transport ,如需指定 handlebars 的模块 ID ,可以在 package.json 的 spm.alias 中配置

0.2.0

  • 如果你不喜欢目录的名字,可以在 package.json 中增加 family 项
  • 支持输出目录位于业务模块目录内
  • 支持 Gruntfile 的自定义任务