静态文件服务器,主要用于KISSY文件转换.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example
lib
test
.gitignore
.jshintrc
.npmignore
.travis.yml
README.md
index.js
package.json

README.md

kserver

npm version npm download npm engines build status Coverage Status npm dependencise

KISSY 静态资源服务, 便于开发调试. 不需要编译js直接运行;

Install

$ npm install --save-dev kserver

options

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
})