Coder Social home page Coder Social logo

fie-plugin-server's Introduction

fie-plugin-server

一键开启本地服务器

说明

本插件用于快速开启本地服务器, 使用了koa ,自动解析本地各种资源文件, 可以直接在命令行调整,也可以在其他套件/插件里面使用.

使用场景

  • 尚未有本地服务器的前端项目可以直接调用
  • 插件,套件里面的可以调用

安装

# 安装 fie (若已安装可忽略)
tnpm install @ali/fie

参数配置

{
    server: {
        // 是否自动打开浏览器
        open: true,
        // 自动打开浏览器后打开哪个页面
        openTarget: 'src/index.html',
        // 端口号
        port: 9000,
        // 是否在控制台打印访问日志
        log: false
    }    
}

用法

开启服务器功能

在命令行里面使用

$ fie server open                打开服务器
$ fie server br [url] -d [delay] 打开浏览器页面,delay为延迟执行毫秒数
$ fie server help                查看帮助信息

在套件/插件里面使用

const fieModule = require('fie-api').module;

const serverInfo = fieModule.get('fie-plugin-server');


const options = {
    callback(app) {
        // app 为 koa 实例
        console.log('本地服务器启动成功');
    }
};

// _fie 为插件/套件获取到的 _fie 对象
yield server.open(_fie, options);

yield server.br(_fie, {
    clientArgs: ['http://taobao.com/'],
    clientOptions: {
        d: 2000
    }
});

使用案例

下图执行了 fie server open 便立即在浏览打开了 http://127.0.0.1:9000/demo/index.html, 并打印访问日志: server open

fie-plugin-server's People

Watchers

James Cloos avatar 宇果 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.