监听端口,利用IP访问自己的静态页面。静态网页位置,可以不必局限于Gruntfile.js所在的目录,可以任意更改。
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');
###注意事项
运行本插件,是在grunt-contrib-watch
的前提下运行的,因为要本模块独立运行无法保证监听的一直运行。
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"
},
});
Type: Number
Default value: 9001
端口为数字型
Type: String
Default value: 127.0.0.1
默认IP为127.0.0.1 ,建议用真实详细IP
Type: String
Default value: ./
相对于Gruntfile.js所在的目录,进行找寻URL的根目录。
shell命令 sudo grunt
即可开启监听
grunt.initConfig({
watch:{
}
mopen: {
options:{
port:9001,
root:"./",
host:"127.0.0.1"
}
},
});
grunt.registerTask('default', ['watch','mopen']);
(0.1.0) 完成了初始化的测试工作 (0.1.1) 基本能完成监听端口的功能 (0.1.2) 修改bug