1.2.2 • Published 10 years ago
kserver v1.2.2
kserver
KISSY 静态资源服务, 便于开发调试. 不需要编译js直接运行;
Install
$ npm install --save-dev kserveroptions
mode: 'kissy', 'define', 'modulex' // 支持三种形式
Demo
var kserver = require('kserver')
kserver({
path: path.join(__dirname, './files'), // required
port: 8181, // 默认: 8080
mode: 'kissy' // 默认: kissy
routes: { // 路由规则
'/xtpl/': { // 文件起始
wrap: false, // 是否编译文件
path: path.join(__dirname, './xtpl') // 重定义目录
}
}
});index.js source
module.exports = {
'a' : 'hello world'
};http get > http://127.0.0.1:8181/index.js return :
// kserver file path:C:\E\github\noyobo\kserver\example\src\index.js
KISSY.add(function(S ,require, exports, module) {
module.exports = {
'a' : 'hello world'
};
});http get > http://127.0.0.1:8181/xtpl/index-render.js return :
// kserver file path:C:\E\github\noyobo\kserver\example\build\xtpl\index-render.js
module.exports = {
'xtpl': 'hello world'
};应用到项目中
KISSY.config({
packages: {
'kserver': {
path: 'http://127.0.0.1:8181',
ignorePackageNameInUri: true
}
}
})
KISSY.use('kserver/', function(S, KS) {
// 实际请求 http://127.0.0.1:8181/index.js
})