javascript前后端混合式代码包管理器xpm,完美支持CommonJS,灵感来自meteor,seajs的spm
发布于 10 年前 作者 xiamidaxia 3580 次浏览 最后一次编辑是 8 年前

代码地址: https://github.com/xiamidaxia/xpm

#Xiami Package Manager

A powerful web server package manager that can manage the client side and server side code together, also bind many useful tools like coffeescript, less, stylus, jade, imagemin, mocha, chai and so on.

Using in the xiami web framework

##documents

中文文档

##tutorials

//init server side code manager
var xpmServer = require('xpm2').serverCreate({
    family: {
        meteor: __dirname + "/meteor",
        //declare your family code path
        myfamily: "/any/real/path"
    }
})

var mypack = xpmServer.require('myfamily/mypack')

console.log(mypack.version)

//init client side code manager
var xpmClient = require('xpm2').clientCreate({
    family: {
        meteor: __dirname + "/meteor",
        myfamily: "/any/real/path"
    },
    dest: __dirname + "/" + "dest"
})

xpmClient.add('myfamily/mypack')
xpmClient.run()

In the ‘mypack’ package directory, you need to add the file package.js just like this:

//just describe
Package.describe({
    info: "this is a mypack package."
    version: "0.0.1"
})
//files you want to use both client side and server side
Package.all({
    files: ["common.js"]
    test_files: ["test/**/*.js"]
})
//files only in server
Package.server({
    imports: ['underscore']             
    files: ['file1.js', 'file2.js']
})
//files in client, you can use many file types like '.less' '.styl' '.tpl' and so on
Package.client({
    imports: ['underscore']             
    files: ['client*.js', "**/*.styl", "**/*.jpg"]
})

1 回复

sj为何要自己弄pm,想不通。。。

回到顶部