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

試著忘記壹切 提交于 2019-12-24 03:52:04

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/30929835/sailsjs-requiring-assets-such-as-sails-io-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!