在多页应用程序中使用RequireJS
我们有一个具有以下结构的多页应用程序: ApplicationModule是根文件夹,其中包含所有应用程序逻辑模块,如Usermanagement和以下其他模块:在多页应用程序中使用RequireJS,requirejs,requirejs-optimizer,Requirejs,Requirejs Optimizer,我们有一个具有以下结构的多页应用程序: ApplicationModule是根文件夹,其中包含所有应用程序逻辑模块,如Usermanagement和以下其他模块: require.config({ paths: { 'jquery': '../../Scripts/jquery', 'appSessionManager': '../../Scripts/ApplicationSessionManager', 'appBasePage': '../../Scripts/A
require.config({
paths: {
'jquery': '../../Scripts/jquery',
'appSessionManager': '../../Scripts/ApplicationSessionManager',
'appBasePage': '../../Scripts/ApplicationBasePage',
'initServices': '../../IntegrationServices/Eservices/EservicesUserManagementService/Authenticate',
'smUtility': '../../Scripts/SmartServicesUtility',
}});
require(['appSessionManager', 'appBasePage', 'initServices', 'smUtility', 'jquery'],
function (sessionManagerRef, basePageRef, eservicesRef, utilityRef)
{
$(document).ready(function () {
//Here is the page code that uses other libraries like appSessionManager, appBasePage and others.
});
});
/应用模块/用户管理
//在userManagement文件夹中,我们有html页面及其相应的.jsmain文件
//所以我们喜欢
login.html和login.js
Login.js反过来需要/加载执行页面逻辑所需的所有脚本文件,因此其配置如下:
require.config({
paths: {
'jquery': '../../Scripts/jquery',
'appSessionManager': '../../Scripts/ApplicationSessionManager',
'appBasePage': '../../Scripts/ApplicationBasePage',
'initServices': '../../IntegrationServices/Eservices/EservicesUserManagementService/Authenticate',
'smUtility': '../../Scripts/SmartServicesUtility',
}});
require(['appSessionManager', 'appBasePage', 'initServices', 'smUtility', 'jquery'],
function (sessionManagerRef, basePageRef, eservicesRef, utilityRef)
{
$(document).ready(function () {
//Here is the page code that uses other libraries like appSessionManager, appBasePage and others.
});
});
现在,在开始生产之前,我们希望使用Optimizer,以便将所有必需的文件连接起来并缩小为单个文件
站在UserManagement文件夹内,我们为优化器运行以下命令:
node.././r.js-o name=Login out=optimize.js
但它给了我们以下错误:
跟踪:登录的依赖项
错误:eNONT,没有这样的文件或目录'D:[某些应用程序路径]\ApplicationModules\UserManagement\appSession
Manager.js'
在模块树中:
登录
at Object.fs.openSync (fs.js:427:18)
错误:错误:eOne,没有这样的文件或目录'D:[某些应用程序路径]\ApplicationModules\UserManagement\app
SessionManager.js'
在模块树中:
登录
at Object.fs.openSync (fs.js:427:18)
对于SessionManager.js文件,错误很明显,它正试图在usermanagement文件夹中查找该文件,但我希望它在Scripts文件夹中查找该文件,如login.js文件的配置路径中所述
如果有人能在这方面帮助我们,我将不胜感激。如果您的问题经过编辑使其易于阅读,您将更有可能获得帮助。谢谢,我已经编辑并试图使其清晰易读。