0.1.1 • Published 7 years ago

neol v0.1.1

Weekly downloads
1
License
ISC
Repository
-
Last release
7 years ago

neol-server


纳尔科技专用前端静态服务器:

  • 静态服务器
  • livereload服务
  • http代理转发

安装

npm install -g neol  // 安装到全局

使用方式

在前端项目根目录,执行neol即可!


配置

neol需要在项目根目录添加neilfile.js文件,为neol服务配置选项, 如果没有添加neolfile.js文件,则全部使用默认配置,具体配置项目如下:

/**
 * 配置文件neolfile.js
 */
module.exports = {
    port: 8080,   // 默认端口配置
    livereload: true,  // 是否开启livereload 自动刷新
    watchFiles: ['./'],  // 要监控的文件/目录
    ignore: [],   // livereload要忽略的文件 (数组, 支持正则表达式) livereload 设置为false时无效  
    exts: [], // livereload需要监控的文件类型  livereload 设置为false时无效
    proxy: false,  // 是否开启代理  默认false
    proxyConfig: { // 代理配置
        '/api': {
            target: 'http://xh.support.neol.cc/',  // 要转发的目标
            pathRewrite: {       // 重写请求路径
                '^/api/': '/'           
            },
            changeOrigin: true
        }
    }, 
};

livereload 使用方法

  1. 在需要启用的网站代码中添加如下代码:
<script>
  document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] +
  ':35729/livereload.js?snipver=1"></' + 'script>')
</script>
  1. 如果使用的是chrome浏览器可以安装livereload插件 点击查看插件