Developing in Sails.js is really slow?

1,157 views
Skip to first unread message

Martin

unread,
Sep 23, 2014, 6:30:51 PM9/23/14
to sai...@googlegroups.com
I have a Virtual Box setup with Ubuntu, node.js, and sails.js. Experiencing tons of waiting between saves so it's really hard to develop.

1. Whenever I restart sails, ie. after making a change to a controller, it takes ~35 seconds to lift.

2. Whenever I save a CSS or JS file, it takes 10+ seconds to show changes in the browser. I see that when I save, sails compiles templates, JS, LESS, etc and moves the files from /assets to /.tmp folder. I have Cache turned off in Google Console so that's not the issue.

Any idea how to speed this up? It's driving me crazy. Making development near impossible.

Is my computer too slow for #1? 

For #2, is it possible to set sails to skip compiling/moving files while in development. Instead just load CSS/JS files directly from the /assets folder. If LESS files, just load them directly in the browser too, and drop in the less.js script in the header, so LESS compiles in-browser (instead of on server).

Rob Wormald

unread,
Sep 23, 2014, 6:32:32 PM9/23/14
to Martin, sai...@googlegroups.com
Two things slow down this part:
1 - as you mentioned, recompiling all your assets.
2- databse schema changes (especially alter)

I switched everything to gulp, and its several orders of magnitude faster.

Martin

unread,
Sep 23, 2014, 6:36:07 PM9/23/14
to sai...@googlegroups.com, 604.we...@gmail.com
Switched grunt to gulp? 

Matthew Marino

unread,
Sep 24, 2014, 12:52:27 AM9/24/14
to sai...@googlegroups.com
A lot depends on the resources the virtual environment has to utilize. I would need to know the specs of your virtual host, amount of cms running and resource allocation to them to provide you with a better answer.

If you would like to try gulp, I have a sails gulp generator suite over on github if you'd like to try them.
https://github.com/Karnith/sails-generate-new-gulp

Martin

unread,
Sep 24, 2014, 2:58:17 AM9/24/14
to sai...@googlegroups.com
Hmm, can't get it working. If I run:

sails generate sails-generate-new-gulp

error: No generator called `sails-generate-new-gulp` found; perhaps you meant `sails generate api sails-generate-new-gulp`?

Is this supposed to generate a new sails.js app using gulp instead? 

Matthew Marino

unread,
Sep 24, 2014, 12:39:35 PM9/24/14
to sai...@googlegroups.com
Did you read the readme? https://github.com/Karnith/sails-generate-new-gulp/blob/master/README.md

$ npm install -g sails-generate-backend-gulp
$ npm install -g sails-generate-gulpfile
$ npm install -g sails-generate-frontend-gulp
$ npm install -g sails-generate-new-gulp

.sailsrc needs to be added to the working dir with the following: (working directory as in the folder that your project is in. eg. if you have a folder nodejs and want to create a project in nodejs folder, the .sailsrc would need to be in the nodejs folder)

-nodejs

--.sailsrc

--newproject

{
    "generators": {
        "modules": {
            "new": "sails-generate-new-gulp",
            "frontend": "sails-generate-frontend-gulp",
            "backend": "sails-generate-backend-gulp",
            "gulpfile": "sails-generate-gulpfile"
        }
    }
}
sails generate sails-generate-new-gulp

Matthew Marino

unread,
Sep 24, 2014, 1:13:14 PM9/24/14
to sai...@googlegroups.com
actually I was mistaken, it should be 

sails new <project name>

I've been working on documentation for it...

Martin

unread,
Sep 29, 2014, 9:08:01 PM9/29/14
to sai...@googlegroups.com
Yeah, so create the .sailsrc file in the root, and then create a new sails app in that folder, right?

Greg

unread,
Dec 5, 2014, 12:55:51 PM12/5/14
to sai...@googlegroups.com
Same problem; on an angular project with a few hundred files in assets it was taking > 10s to see my changes. 

For development I now disable grunt and instruct Sails to serve assets directly from /assets. 

add .sailsrc with the following content

"hooks": { "grunt": false }
}

modify config/env/development.js to include the following 

// serve assets directly in development! 
paths: {
public: process.cwd()+'/assets' // or wherever
},
Reply all
Reply to author
Forward
0 new messages