我在我的应用程序上遇到了 Require 加载超时错误。我正在使用 grunt 和 require 优化器构建我的 require 文件。我已经设置了一个等待秒,并且已经看到我的本地超时消失了,但它仍然发生在 prod 中。我已经在我的 grunt 文件中设置了等待秒数,但也尝试了我的主 js 文件,但看不到它们被推送到活动脚本文件的位置。有谁知道我在哪里可以找到产品中的这个值?当 grunt 运行任务时它不会被写入 require.js 文件,并且当 require 和优化器运行时它不包含在我的 main.js 文件中。浏览器在哪里获取这个值?我在 prod 上的 require.js 文件中看到最初的 7 秒超时,但找不到我的选项在哪里被选中。
这是我的要求咕噜任务:
requirejs: {
options: {
baseUrl: ".",
appDir: "js",
waitSeconds: 40,
findNestedDependencies: true,
mainConfigFile: "js/common.js",
dir: "../assets/js",
paths: {
"rs": "mains/recordsearch"
},
optimize: "none",
// modules to be optimized and bundled
// "include" and "exclude" can be used here
// to add or ignore dependencies
modules: [{
name: "common"
}, {
name: "rs/home"
}, {
name: "commons/html5shim"
}]
},
dev: {},
prod: {
options: {
optimize: "uglify"
}
}
},
我的“主要”需要js页面:
requirejs.config({
paths: {
// libraries path
"jquery": "libs/jquery",
"jquery-ui": "libs/jquery-ui",
"modernizr": "libs/modernizr.custom",
// validation
"boolean": "validation/custom/boolean",
"comparefield": "validation/custom/comparefield",
"expirationdate": "validation/custom/expirationdate",
"securitycode": "validation/custom/securitycode",
"fullname": "validation/custom/fullname",
"zip": "validation/custom/zip",
"ajaxval": "validation/framework/jquery.unobtrusive-ajax.min",
"vsdoc": "validation/framework/jquery.validate-vsdoc",
"validate": "validation/framework/jquery.validate.min",
"unobtrusive": "validation/framework/jquery.validate.unobtrusive.min",
// plugins
"acmodal": "plugins/acmodal",
"acbutton": "plugins/acbutton",
"acnav": "plugins/acnav",
"actooltip": "plugins/actooltip",
// utils and polyfills
"bridge": "utils/pluginbridge",
"object.create": "polyfills/object.create",
"counter": "utils/counter",
// funnels
"rs": "mains/recordsearch"
},
// The shim section allows you to specify
// dependencies between non AMD compliant files.
shim: {
"jquery": {
exports: "$"
},
"modernizr": {},
"acbutton": ["jquery", "object.create", "bridge"],
"acnav": ["jquery", "object.create", "bridge", "modernizr"],
"acmodal": ["jquery", "object.create", "bridge", "jquery-ui"],
"actooltip": ["jquery", "object.create", "bridge", "counter"],
"ajaxval": ["validate", "unobtrusive", "boolean", "comparefield", "expirationdate", "comparefield", "boolean", "fullname", "zip", "securitycode"]
},
});
require([
"jquery",
"ajaxval",
"actooltip",
"acbutton",
"acnav",
"acmodal",
"commons/errorhandling"
], function () {
//waiting until dom is loaded to load the page modules
$(function () {
// the start module is defined on the body tag.
// example: <body data-jspage="rs/main"> or <body data-jspage="rs/main, rs/common">
var startModule = $("body").attr("data-jspage");
var siteArea = $("body").attr("data-area");
if (startModule) {
require([startModule]);
}
if (siteArea === "FE") {
require(["commons/signin"]);
}
});
});
提前感谢您的任何反馈。