简介
22 |23 | LiveNode是一个基于Node.js轻巧的web服务,帮助前端开发者解决本地跨域,代码刷新,以及SPA(单页应用)前后端服务分离,并且可以用于生产环境项目部署。 24 |
25 |├── .gitignore ├── .gitattributes ├── src ├── img │ ├── 404.png │ ├── npm.png │ ├── gitHub.png │ ├── logo.png │ └── binlive-logo.png ├── data │ └── test.json ├── notFound.html ├── css │ └── style.css ├── index.html └── js │ └── jquery.min.js ├── config.js ├── package.json └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.html linguist-language=javascript 2 | -------------------------------------------------------------------------------- /src/img/404.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hzy0913/LiveNode/HEAD/src/img/404.png -------------------------------------------------------------------------------- /src/img/npm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hzy0913/LiveNode/HEAD/src/img/npm.png -------------------------------------------------------------------------------- /src/img/gitHub.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hzy0913/LiveNode/HEAD/src/img/gitHub.png -------------------------------------------------------------------------------- /src/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hzy0913/LiveNode/HEAD/src/img/logo.png -------------------------------------------------------------------------------- /src/img/binlive-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hzy0913/LiveNode/HEAD/src/img/binlive-logo.png -------------------------------------------------------------------------------- /src/data/test.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es5", 5 | "sourceMap": true 6 | }, 7 | "exclude": [ 8 | "node_modules" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /config.js: -------------------------------------------------------------------------------- 1 | const port = 3000; 2 | const reload = true; 3 | const spaHistory = false; 4 | const notFound = '/notFound.html'; 5 | const proxyTable = [ 6 | { 7 | host: 'http://www.binlive.cn', 8 | api: '/api/testApi' 9 | } 10 | ]; 11 | 12 | 13 | 14 | 15 | module.exports = {reload, proxyTable, port, spaHistory, notFound}; 16 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "LiveNode", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "build", 6 | "scripts": { 7 | "start": "pm2 start build/dev-server.js", 8 | "build": "pm2 start build/build.js -i max --watch", 9 | "restart": "pm2 restart all", 10 | "stop": "pm2 stop all", 11 | "list": "pm2 list" 12 | }, 13 | "license": "ISC", 14 | "dependencies": { 15 | "browser-sync": "^2.23.6", 16 | "connect-timeout": "^1.9.0", 17 | "express": "^4.16.3", 18 | "http-proxy-middleware": "^0.18.0", 19 | "pm2": "^2.10.2" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/notFound.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 7 | 8 | 9 | 10 |
15 |
16 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/src/css/style.css:
--------------------------------------------------------------------------------
1 | body{padding: 0;margin: 0px}
2 | .container{width: 500px; margin: 0 auto;padding-top: 10%;padding-bottom: 100px}
3 | .logo{width: 500px; margin: 0 auto}
4 | .title{color: #33333d;font-size: 16px;font-weight: 500;text-align: center}
5 | .page{background-color: #fdfdfd;border-top: 1px solid #eee;padding-top: 100px;padding-bottom: 100px}
6 | .page .content{width: 800px; margin: 0 auto;}
7 | .page .content h1{color: #222c36}
8 | .page .content p{color: #33333d;font-size: 15px;letter-spacing: .5px}
9 | .notfound{width: 80%; margin: 0 auto;display: block}
10 | .binlive-logo{width: 80px;position: fixed;right: 20px; top: 20px;z-index: 99}
11 | .code{font-size: 14px;color: #333;border: 1px solid #f2f3f3; background-color: #f6f8fa;padding: 10px;padding-left: 20px;border-radius: 3px}
12 | .title-link{text-decoration: none;color: #00a2ae;display: inline-block}
13 | .title-link:hover{color: #0b737b}
14 | .link-logo{width: 20px;text-decoration:none;float: left;margin: 0px 4px;}
15 | .document span{float: left}
16 | .document{overflow: hidden}
17 | @media (max-width: 600px) {
18 | body{zoom: 0.4}
19 | }
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
17 | 23 | LiveNode是一个基于Node.js轻巧的web服务,帮助前端开发者解决本地跨域,代码刷新,以及SPA(单页应用)前后端服务分离,并且可以用于生产环境项目部署。 24 |
25 |全局安装LiveNode脚手架工具
31 |npm install livenode-cli -g
32 |创建项目
38 |livenode init
39 |根据提示输入项目文件名称(不输入则生成默认名称)
40 |project name: my-project
41 |输入要创建的项目模版(不输入内容即生成多页项目模板,输入 spa 则生成单页面应用项目模版)
42 |project templat: spa
43 |cd进入生成的项目目录后,安装项目所需依赖
44 |cd my-project
45 |npm install
46 |npm start
52 |启动开发环境下的node.js服务
53 |npm restart
54 |重启node.js服务,在开发环境下修改config.js配置文件后需要执行该命令重启服务
55 |npm build
56 |启动生产环境下的node.js服务,在生产环境下修改配置文件不需要再执行npm restart命令重启,npm build会默认监听配置文件修改并自动重启服务。
57 |npm stop
58 |停止node.js服务
59 |npm run list
60 |查看node.js服务的状态
61 |