gpt4 book ai didi

jquery - SailsJS v0.10.0-rc7/grunt 以正确的顺序加载 js 资源

转载 作者:行者123 更新时间:2023-12-03 22:25:07 25 4
gpt4 key购买 nike

我正在尝试学习 SailsJS,但是由于缺乏有关新版本 Sails 的文档,我遇到了一些困难。

好的,链接器已被删除...并且我的 gruntfile.js 与 sailscasts 中的不同。

我正在运行 sails v0.10.0-rc7,这与网站上针对 v0.9.0 的文档不同。

如何修改 gruntfile 以在引导之前加载 jquery?更好的是,是否可以转储 grunt 并运行 gulp?

提前致谢。

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);

};

最佳答案

找到了解决方案 - 但找不到任何相关文档...

需要编辑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'
];

关于jquery - SailsJS v0.10.0-rc7/grunt 以正确的顺序加载 js 资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24002520/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com