我会为 yeoman + expressjs 推荐这种结构:
mkdir app
cd app
yeoman angular
express .
所以你的目录树应该是这样的:
.
├── 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
您可以删除现在冗余的public
目录(我们将改为从中提供服务app
):
rm -rf public
现在app.js
,您需要更改从哪个目录提供静态文件。更改此行:
app.use(express.static(path.join(__dirname, 'public')));
对此:
app.use(express.static(path.join(__dirname, 'app')));
这应该是关于它的。需要注意的是,您现在有两个“索引”文件——一个在 中views/index.jade
,另一个在app/index.html
. 删除app/index.html
当前中断的 yeoman,所以我的建议是摆脱路线app/index.jade
并仅对index.html
.
希望这可以帮助!