Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SailsJS v0.10.0-rc7 / grunt loading js assets in correct order

I am trying to learn SailsJS, however am experiencing some difficulties with lack of documentation on a newer version of Sails.

Ok, so Linker has been removed... And my gruntfile.js is different to that in sailscasts.

I am running sails v0.10.0-rc7which is different to the documentation on the website which is for v0.9.0.

How do I modify my gruntfile to load jquery before bootstrap? Even better, is it possible to dump grunt and run gulp instead?

Thanks in advance.

http://irlnathan.github.io/sailscasts/blog/2013/08/22/building-a-sails-application-ep2a-a-quick-supplement-to-some-stuff-i-forgot-to-mention-in-episode-2/

/**
 * Gruntfile
 *
 * This Node script is executed when you run `grunt` or `sails lift`.
 * It's purpose is to load the Grunt tasks in your project's `tasks`
 * folder, and allow you to add and remove tasks as you see fit.
 * For more information on how this works, check out the `README.md`
 * file that was generated in your `tasks` folder.
 *
 * WARNING:
 * Unless you know what you're doing, you shouldn't change this file.
 * Check out the `tasks` directory instead.
 */

module.exports = function(grunt) {


    // Load the include-all library in order to require all of our grunt
    // configurations and task registrations dynamically.
    var includeAll;
    try {
        includeAll = require('include-all');
    } catch (e0) {
        try {
            includeAll = require('sails/node_modules/include-all');
        }
        catch(e1) {
            console.error('Could not find `include-all` module.');
            console.error('Skipping grunt tasks...');
            console.error('To fix this, please run:');
            console.error('npm install include-all --save`');
            console.error();

            grunt.registerTask('default', []);
            return;
        }
    }


    /**
     * Loads Grunt configuration modules from the specified
     * relative path. These modules should export a function
     * that, when run, should either load/configure or register
     * a Grunt task.
     */
    function loadTasks(relPath) {
        return includeAll({
            dirname: require('path').resolve(__dirname, relPath),
            filter: /(.+)\.js$/
        }) || {};
    }

    /**
     * Invokes the function from a Grunt configuration module with
     * a single argument - the `grunt` object.
     */
    function invokeConfigFn(tasks) {
        for (var taskName in tasks) {
            if (tasks.hasOwnProperty(taskName)) {
                tasks[taskName](grunt);
            }
        }
    }




    // Load task functions
    var taskConfigurations = loadTasks('./tasks/config'),
        registerDefinitions = loadTasks('./tasks/register');

    // (ensure that a default task exists)
    if (!registerDefinitions.default) {
        registerDefinitions.default = function (grunt) { grunt.registerTask('default', []); };
    }

    // Run task functions to configure Grunt.
    invokeConfigFn(taskConfigurations);
    invokeConfigFn(registerDefinitions);

};
like image 323
Gravy Avatar asked Jun 02 '14 20:06

Gravy


1 Answers

Found the solution - couldn't find any documentation for this though...

need to edit tasks/pipeline.js

// Client-side javascript files to inject in order
// (uses Grunt-style wildcard/glob/splat expressions)
var jsFilesToInject = [

  // Dependencies like sails.io.js, jQuery, or Angular
  // are brought in here
  'js/dependencies/jquery.js',
  'js/dependencies/bootstrap.js',
  'js/dependencies/angular.js',
  'js/dependencies/**/*.js',


  // All of the rest of your client-side js files
  // will be injected here in no particular order.
  'js/**/*.js'
];
like image 94
Gravy Avatar answered Nov 09 '22 20:11

Gravy