2

Sorry for the noob question but I'm trying to start up a new application with Sails and include my assets. I'm using Bower to manage my packages for things like Bootstrap and JQuery. I had a read of this question and added a .bowerrc file which is now installing my Bower components to /assets.

I'm now confused as to how I should proceed to add these files into my project. It seems as though I can't just do a <script> tag in the header as I'm used to because it's giving me a file not found. Reading through the sails documentation it seems like Grunt should be creating a .tmp/public/assets folder in my project, but whenever I run sails lift and go to .tmp/ there is nothing in there.

I also read in the documentation that I should be using some kind of asset injection, I tried adding this to my HTML and it seems like it doesn't do anything.

My other question is around how I go about referencing images in my HTML. Obviously I can't just do something like src='assets/images/image.png, how should I go about this? Is there something really obvious that I'm missing?

Community
  • 1
  • 1
samturner
  • 2,213
  • 5
  • 25
  • 31

1 Answers1

0

Sails use grunt tasks to do lot of things during lift and build. You can get much better look how everything work if you take some time and check what is inside Gruntfile.js from root of your sails project. About your specific question here is some information: - from sails docs: "In order to take advantage of asset injection, minification, and concatenation you must put your assets in folder under assets/linker". This exactly mean that everything what you will put inside assets/linker directory will be affected by grunt tasks during lift. It mean that all files/directories from linker will be copy to .tmp/public and also some of that files will be processed before saved to .tmp/public. - About adding tags. If you take a look at Gruntfile.js you will find this variables: var cssFilesToInject = [...] and var jsFilesToInject = [...] which contain files that will be automatic added to layout header during sails lift. - About your 'other question', yes you can do something like 'src='linker/images/image.png' if you move that files to linker directory (assets/linker).

I hope this help :).

zmilan
  • 1,142
  • 17
  • 19
  • There's no way to just reference an asset that's already in the `assets` folder? That doesn't seems right... *"Upon lifting, a file called myApp/assets/newFolder/data.txt could be accessed at http://localhost:1337/newFolder/data.txt"*. (http://sailsjs.org/#!/documentation/anatomy/myApp/assets) – Cody Jun 19 '15 at 15:05