sheSite是一个快速优雅的建站框架,sheSite基于Node.js框架Koa
环境变量NODE_SITE_CLEAN=delete
koa-static
准备
sheSite安装和运行需要有npm和Node.js。
下载Node.js,安装后命令行有npm命令。
$ npm i sheSite
sheSite是做什么用的
sheSite是一个快速优雅的建站框架
const Koa = ;const app = ; // responseapp; app;
用sheSite制作一个简单网站
制作更复杂的网站
MIME
- Kick-Off-Koa - An intro to Koa via a set of self-guided workshops.
- Workshop - A workshop to learn the basics of Koa, Express' spiritual successor.
webpack整合
创建package.json,或npm init,然后添加script,恭喜!您的网站就已经建好了:
- async function
- common function
注意删除文件夹
建一个网站需要做什么?什么都不用做!
app;
sheSite的特殊目录
// Middleware normally takes two parameters (ctx, next), ctx is the context for one request,// next is a function that is invoked to execute the downstream middleware. It returns a Promise with a then function for running code after completion. app;
配置
- 创建一个文件夹。
Old signature middleware support will be removed in v3
Please see the Migration Guide for more information on upgrading from v1.x and using v1.x middleware with v2.x.
加入我们
@目录
app;
本地服务器启动
Koa's Request
object provides helpful methods for working with
http requests which delegate to an IncomingMessage
from the node http
module.
文件层级的中间件架构
app;
访问我的页面。
目录里每一个文件就是一个网址,如/index.html就是http://locaohost/index.html
koa-webpack-dev-middleware
app;
src
For more information on Request
, Response
and Context
, see the Request API Reference,
Response API Reference and Context API Reference.
作为静态服务器
外部文件管理
webpack entry
Learn more about the application object in the Application API Reference.
作为node服务器
生产模式
If you're not using node v7.6+
, we recommend setting up babel
with babel-preset-env
:
$ npm install babel-register babel-preset-env --save
koa
;
热更新:
动静结合
Check the Troubleshooting Guide or Debugging Koa in the general Koa guide.
动态路由
$ npm run sheSite
作者
Jeffrey Li
社区
- Badgeboard and list of official modules
- 中文文档 v2.x
- #koajs on freenode
开发模式
创建你的页面。
赞助我们
启动服务器.
cdn发送
你的网站已经可以用了,打开浏览器访问你的页面。
License
MIT