Cody
Cody

Reputation: 10025

SailsJS: Requiring Assets, Such As, sails.io.js

As the problem is short & sweet, I'll keep the question so.

CAN'T LOAD ASSETS.

Using Sails.js (v0.11.n).

Can't load assets... That's about it...

I'm trying to load sails.io.js -- or now even just assets/alert.js.

<script type="text/javascript" src="/js/dependencies/sails.io.js"></script> Doesn't work :(

Even when I switch the src to /alert.js -- nothing.

I'm pasting this script tag inside of my /signup view -- which loads fine -- but I know sure as heck I'm doing something(s) wrong.

Upvotes: 2

Views: 215

Answers (2)

sgress454
sgress454

Reputation: 24958

This was due to an issue with the sails new app generator that has been fixed. The issue was that for any new app, the Grunt hook would be disabled, so that your assets would not be copied automatically into your app's .tmp/public folder at lift time. This is only supposed to happen if the --no-front-end option is used with sails new, but it was happening all the time. You can check for this problem by looking in your app's .sailsrc file; if you see:

"hooks": {
   "grunt": false
}

remove it, and your assets will be accessible again.

Upvotes: 2

Will Ricketts
Will Ricketts

Reputation: 46

Grunt is taking care of the asset pipeline for you. If you look in the source for layout.ejs, you'll find some tags for your assets. Grunt is automatically looking into the assets folder, and is including them into your layout.

Upvotes: 1

Related Questions