rerich
rerich

Reputation: 277

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.

Upvotes: 2

Views: 1416

Answers (2)

Juan Picado
Juan Picado

Reputation: 1996

The previous answer clearly doesn't work on latest versions of sails.js. According this you cannot change paths unless you use the .sailsrc.

eg:

{
  "paths": {
        "tmp": "dist/assets",
        "public": "dist/assets"
    }
}

Upvotes: 3

Nitsew
Nitsew

Reputation: 3662

You can find a couple of different answers here: https://github.com/balderdashy/sails/issues/709

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

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

Update:

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"
};

Upvotes: 2

Related Questions