rerich rerich - 2 years ago 198
Javascript Question

sails.js - change public folder to be different than .tmp/public

I reworked sails.js assets flow to fit my needs. I am storing my public assets in /assets/dist.

Is there any easy way to configurate sails app to use my own public folder instead of default "/.tmp/public"?

I know there is option to configure this via /config/local.js, but i want configure this elsewhere(if possible) so it will not be related just to current machine and it will be included in git repo.

Answer Source

You can find a couple of different answers here:

Looks like the easiest way is adding this to your config/local.js file:

path: {tmp: ..., public: ...}


You can find the default paths settings by navigating to: node_modules/sails/lib/app/configuration/index.js. If you scroll near the bottom of that file, you will see this:

// Built-in path defaults
paths: {
    tmp: path.resolve(appPath, '.tmp')

If you create a new file in your config folder called paths.js and add this code to it, you can overwrite/add more default paths to your sails application:

module.exports.paths = {
    "tmp" : "assets/dist",
    "public" : "assets/dist"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download