Skip to content

fyddaben/grunt-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mopen

监听端口,利用IP访问自己的静态页面。静态网页位置,可以不必局限于Gruntfile.js所在的目录,可以任意更改。

Getting Started

This plugin requires Grunt ~0.4.2

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install mopen --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('mopen');

The "mopen" task

###注意事项 运行本插件,是在grunt-contrib-watch的前提下运行的,因为要本模块独立运行无法保证监听的一直运行。

Overview

In your project's Gruntfile, add a section named mopen to the data object passed into grunt.initConfig().

grunt.initConfig({
  mopen: {
    //端口
    port:9001,
    //URL根目录的相对路径
    root:"./",
    //本机IP地址
    host:"127.0.0.1"
  },
});

Options

options.port

Type: Number Default value: 9001

端口为数字型

options.host

Type: String Default value: 127.0.0.1

默认IP为127.0.0.1 ,建议用真实详细IP

options.root

Type: String Default value: ./

相对于Gruntfile.js所在的目录,进行找寻URL的根目录。

使用实例

Default Options

shell命令 sudo grunt 即可开启监听

grunt.initConfig({
    watch:{
        
    }
    mopen: {
        options:{
    port:9001,
    root:"./",
    host:"127.0.0.1"
  }
  },
});
grunt.registerTask('default', ['watch','mopen']);

Release History

(0.1.0) 完成了初始化的测试工作 (0.1.1) 基本能完成监听端口的功能 (0.1.2) 修改bug

About

open url simple,u must install grunt-contrib-watch first.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published