Since Sails is a pure framework, and Angular is a purely front-end, they can work well together. This may be a bit confusing when you introduce the Angular generator into it, but here are the basic steps if you were to start with Angular Seed and Sails v0.10:
- Create a new Sails application with
sails new myApp - Destroy the contents of the
myApp/assets folder - Copy the contents of the Angular Seed
app folder to myApp/assets - Replace the contents of
myapp/views/layout.ejs with the contents of the Angular Seed app/index.html file - Cut the contents of the script tag from the
layout.ejs file (everything after the <body> and before the first <script> and use it to replace the contents of myApp/views/homepage.ejs - Place
<%-body%> after the <body> in layout.ejs
Then you can start the server using sails lift and you will see the Angular application at http://localhost:1337 .
I put this on github for reference.
Using this method, you donβt need to do anything with the Gruntfile, and you will never call the grunt server - it is only for testing Angular applications with your test server, which you replace Sails, you can still use the Sailing grunt-sync task, which tracks and synchronizes your front-end assets as they change.
If you really want to use the Yeoman Angular generator, you can try to create the application directly in the assets folder of your Sails application and use the generator commands from this folder. I have not used it before, so I donβt know what the dist folder is for, but it looks like all the node modules it installs support a test web server there (which you don't need again, since you have Sails) and a set of tests (which is always nice). The only problem I see is if you need some tasks in this Gruntfile that Yeoman generates. Sails handles less CSS compilation and minimization (in production mode), but it does nothing with Jade or Stylus, so you'll have to add these tasks to the Sails Gruntfile if you really need them.
sgress454 Feb 22 '14 at 8:25 2014-02-22 08:25
source share