里面防爆pressJS约曼 [英] Yeoman inside ExpressJS

查看:95
本文介绍了里面防爆pressJS约曼的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还是想尝试获得一个实例运行瓦特/约曼和Ex preSS。

I'd still like to try to get an example running w/ Yeoman and Express.

我尝试以下和它的工作好,但我坚持融合的路由。 (在简化的可读性)

I tried the following and it worked "okay", but I'm stuck merging the routes. (over simplified for readability)

mkdir test
cd test
express
mkdir app
cd app
mkdir js
cd js
yeoman angular

然后,我改变输出:DIST到输出:../​​../公在Gruntfile.js

Then I changed "output:dist" to "output:../../public" in the Gruntfile.js

现在,两台服务器上运行好自己的(例如自耕农服务器和节点app.js)。我还可以运行自耕农构建现在输出缩小的JS来/公众在EX preSS应用程序。

Now, both servers run okay on their own (e.g. yeoman server and node app.js). I can also run 'yeoman build' now to output the minified JS to /public in the express app.

我有点模糊的路线会如何合并?我想/拉起角路线,而不是前preSS路线等在GitHub上角前preSS种子的例子看起来不错,但我还是想约曼集成到项目中。

I'm a bit fuzzy on how the routes might merge? I would like / to pull up the Angular route and not the express route, etc. The angular-express-seed examples on github look okay, but I would still like Yeoman integrated into the project.

任何建议将是AP preciated。

Any suggestions would be appreciated.

推荐答案

我会建议自耕农+ EX pressjs此结构:

I would recommend this structure for yeoman + expressjs:

mkdir app
cd app
yeoman angular
express .

所以,你的目录树应该是这样的:

So your dir tree should look like this:

.
├── app
│   ├── 404.html
│   ├── favicon.ico
│   ├── index.html
│   ├── robots.txt
│   ├── scripts
│   │   ├── controllers
│   │   │   └── main.js
│   │   ├── vendor
│   │   │   ├── angular.js
│   │   │   ├── angular.min.js
│   │   │   ├── es5-shim.min.js
│   │   │   └── json3.min.js
│   │   └── yeoman-test.js
│   ├── styles
│   │   └── main.css
│   └── views
│       └── main.html
├── app.js
├── Gruntfile.js
├── package.json
├── public
│   ├── images
│   ├── javascripts
│   └── stylesheets
│       └── style.css
├── routes
│   ├── index.js
│   └── user.js
├── test
│   ├── lib
│   │   └── angular-mocks.js
│   └── spec
│       └── controllers
│           └── main.js
├── testacular.conf.js
└── views
    ├── index.jade
    └── layout.jade

您可以删除多余的,现在公共目录(我们打算从应用改为放送):

You can remove the now redundant public directory (we're going to serve from app instead):

rm -rf public

和现在 app.js ,您需要更改目录,从提供静态文件。改变这一行:

And now in app.js, you need to change which dir to serve static files from. Change this line:

app.use(express.static(path.join(__dirname, 'public')));

这样:

app.use(express.static(path.join(__dirname, 'app')));

这应该是它。有一个在一个careat你现在有两个指数的文件 - 一个在的意见/ index.jade ,和其他在应用程序/索引。 HTML 。删除应用程序/ index.html的打破目前自耕农,所以我的建议是要摆脱路径为应用程序/ index.jade 和刚进行编辑 index.html的

And that should be about it. There's one careat in that you now have two "index" files -- one in views/index.jade, and the other in app/index.html. Removing the app/index.html currently breaks yeoman, so my advice is to get rid of the route for app/index.jade and just make edits to index.html.

希望这有助于!

这篇关于里面防爆pressJS约曼的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆