Since Sails is a purely back-end framework and Angular is purely front-end, they can work together nicely. It can get a little confusing when you bring the Angular generator into it, but here are the basic steps if you were to start with the Angular Seed app and Sails v0.10:
- Create a new Sails app with
sails new myApp
- Wipe out the contents of the
myApp/assets
folder
- Copy the contents of the Angular Seed
app
folder into myApp/assets
- Replace the contents of
myapp/views/layout.ejs
with those of the Angular Seed app/index.html
file
- Cut all of the non-script tag content from the
layout.ejs
file (everything after the <body>
tag and before the first <script>
tag and use it to replace the contents of myApp/views/homepage.ejs
- Place
<%-body%>
after the <body>
tag in layout.ejs
You can then start the server with sails lift
and you'll see the Angular app at http://localhost:1337
.
I've put this on Github for reference.
Using this method, you don't need to do anything to the Gruntfile, and you'll never call grunt server
--that's solely for testing Angular apps with their test server, which you're replacing with Sails. You'll still get the benefit of the Sails grunt-sync task which watches and syncs-up your front-end assets as they are changed.
If you really want to use the Yeoman Angular generator, you can try generating an app directly into the assets
folder of your Sails app and using the generator commands from within that folder. I haven't used it before, so I don't know what the dist folder is for, but it seems like all of the node modules it installs are there to support the test web server (which again you don't need, since you have Sails) and the test suite (which is always nice). The only issue I can see is if you need some of the tasks in that Gruntfile that Yeoman generates. Sails handles Less compilation and CSS minification (in production mode), but it doesn't do anything with Jade or Stylus, so you'd have to add those tasks to the Sails Gruntfile if you really needed them.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…