Caweren
Caweren

Reputation: 244

Sails.js + grunt doesn't compile assets

I'm all new to the whole NodeJS storm, and after some research, i decided to use Sails.JS as my framework.

It all works fine, untill i try to use the Bootstrap Bootswatch .less files.

If i copy the bootswatch.less into my styles folder, and refresh the page, all of my assets throws a 404 error.

My directory tree looks like this:

Root
|_api
|_assets
|_|_images
|_|_linker
|_|_|_fonts
|_|_|_js
|_|_|_styles
|_|_|_|_bootstrap.css
|_|_|_|_custom.less
|_|_|_|_variables.less
|_|_|_|_bootswatch.less
|_|_|_templates
|_configs
etc.

My gruntfile.js lookslike this:

var cssFilesToInject = [

'linker/styles/variables.less',
'linker/styles/bootstrap.css',
'linker/styles/bootswatch.less',
'linker/styles/custom.less',

'linker/**/*.css'
];

i've tried to start the server with sails lift --verbose, and no errors was thrown.

Upvotes: 1

Views: 684

Answers (2)

Grant Eagon
Grant Eagon

Reputation: 1400

Had the same problem, but found a better solution–albeit, not perfect. Basically, you run grunt compileAssets in your project root. If that works, we're on the right track.

It would be better to fix the real problem that sails isn't compiling assets when it lifts.

So here's what worked for me:

I dug through the grunt files to get a limited understanding of what's going on. Since compiling assets manually worked, it seemed like Grunt was functioning properly. Then I stumbled onto a .sailsrc file in my project root. Here's what it looked like:

{
  "generators": {
    "modules": {}
  },
  "hooks": {
    "grunt": false
  }
}

It looked like Grunt was turned off. I changed it to this, lifted sails and it worked!

{
  "generators": {
    "modules": {}
  },
  "hooks": {
    // "grunt": false
  }
}

I don't really know what's this does yet, so maybe it's a janky solution, but it let me get back to work. When I gain more experience with Sails, if this isn't right I'll fix it properly.

Upvotes: 1

Raptus
Raptus

Reputation: 495

Good choice of Framework there! Sails is awesome and can creates a mean stack with Angular.js, anyway everything I've seen of Sails.js auto-compilation is a sticky business at best, as there are many topics on the issue.

I too ran into the issue with making it work with SCSS files.

Overal I think it would be best if you manually compiled the files with whatever terminal you use and link it to the styles directory.

If you manage to find another way that's great, however the reason the assets are not compiling may be due to a huge number of factors you will spend hours trying to sort out.

Upvotes: 0

Related Questions