Assets refer to static files (js, css, images, etc.) on your server that you want to make accessible to the outside world. In Sails, these files are placed in the
assets/ folder. When you lift your app, add files to your
assets/ folder, or change existing assets, Sails' built-in asset pipeline processes and syncs those files to a hidden folder (
This intermediate step (moving files from
.tmp/public/) allows Sails to pre-process assets for use on the client - things like LESS, CoffeeScript, SASS, spritesheets, Jade templates, etc.
The contents of this
.tmp/public folder are what Sails actually serves at runtime. This is roughly equivalent to the "public" folder in express, or the
www/ folder you might be familiar with from other web servers like Apache.
Like most web servers, Sails honors the
index.html convention. For instance, if you create
assets/foo.html in a new Sails project, it will be accessible at
http://localhost:1337/foo.html. But if you create
assets/foo/index.html, it will be available at both
It is important to note that the static middleware is installed after the Sails router. So if you define a custom route, but also have a file in your assets directory with a conflicting path, the custom route will intercept the request before it reaches the static middleware. For example, if you create
assets/index.html, with no routes defined in your
config/routes.js file, it will be served as your home page. But if you define a custom route,
'/': 'FooController.bar', that route will take precedence.