我有一個可以在Apache上跑的靜態(tài)angular項目,想在想把它遷移到node環(huán)境里去,不知道該怎么寫node的server.js和page.json.
光陰似箭催人老,日月如移越少年。
用KOA這么寫就行
var koa = require('koa');
var serve = require('koa-static');
var path = require('path');
// KOA框架
var app = module.exports = koa();
// 錯誤處理
app.on('error', function(err, ctx){
console.log(err.message);
});
// 靜態(tài)中間件
app.use(serve(path.join(__dirname, 'public')));
// 監(jiān)聽端口
if (!module.parent){
app.listen(3000);
logger.info('My Website run on 3000...');
}
/app.js
/public/index.html //angular入口
用 nokit,一行命令:
$ cd <angular項目目錄>
$ nokit start <port> -public:./
更詳細的用法,查看 http://nokit.org
直接放在靜態(tài)文件里面吧,使用后直接訪問靜態(tài)頁面地址就行,這個游戲就是這么搞的
http://tianmaying.com/app/collect-b/index.html
嘿嘿,試試sero-cli吧,第二項“Start a static web server for current working directory”,在你的angular項目根目錄里使用這個命令,選第二項就可以了。