我正在尝试optimize my Durandal app但是main-built.js是空白的。
我尝试过运行node r.js -o app.build.js
,这引发了一条错误,说无法找到文件。我在main.js文件中添加了这些路径,每个错误都消失了。但是,现在上面的命令只退出“跟踪依赖关系:durnadal / amd / almond.custom”,文件仍为空白。
问题:哪些图书馆需要进入以下路径?在我的index.html中使用的外部库似乎需要确切的文件名吗?
require.config({
paths: {
"text": "durandal/amd/text",
"breeze": "lib/breeze/breeze.min",
"knockout": "lib/knockout/knockout.mapping-latest",
}
});
当我在Durandal AMD文件夹中运行Optimizer.exe时,main-built.js为空。这是生成的app.build.js文件 - 有关如何使用Almond进行更详细的日志记录的任何帮助。我试过optimizer -verbose true
没有运气。
{
"name": "durandal/amd/almond-custom",
"inlineText": true,
"stubModules": [
"durandal/amd/text"
],
"paths": {
"text": "durandal/amd/text"
},
"baseUrl": "C:\\DNNDev.me\\DesktopModules\\Framework.App\\App",
"mainConfigFile": "C:\\DNNDev.me\\DesktopModules\\Framework.App\\App\\main.js",
"include": [
"text!about.html",
"about",
"appNavigation",
"config",
"text!dareAdd.html",
"dareAdd",
"text!dareDetail.html",
"dareDetail",
"text!dareList.html",
"dareList",
"text!dareListItem.html",
"dataContext",
"dataService",
"dataServiceHelper",
"enums",
"errorWatcher",
"text!home.html",
"home",
"text!index.html",
"text!indextopcoat.html",
"indextopcoat",
"text!kendoIndex.html",
"text!loader.html",
"logger",
"text!login.html",
"login",
"main-built",
"main",
"text!menu.html",
"model",
"text!navbar.html",
"text!notifyOfError.html",
"notifyOfError",
"text!privacy.html",
"privacy",
"text!profile.html",
"profile",
"text!shell.html",
"shell",
"text!signup.html",
"signup",
"text!testpage.html",
"testpage",
"uiutilities",
"userState",
"viewModelHelper",
"text!walkthrough.html",
"walkthrough",
"widgetService",
"css/telerik/js/kendo.dataviz.min",
"css/topcoat/js/hello",
"css/topcoat/js/hello.min",
"css/topcoat/js/index",
"css/topcoat/lib/hello",
"css/topcoat/lib/vendor/ender.min",
"css/topcoat/lib/vendor/fastclick",
"durandal/app",
"durandal/composition",
"durandal/events",
"durandal/http",
"text!durandal/messageBox.html",
"durandal/messageBox",
"durandal/modalDialog",
"durandal/system",
"durandal/viewEngine",
"durandal/viewLocator",
"durandal/viewModel",
"durandal/viewModelBinder",
"durandal/widget",
"durandal/plugins/router",
"durandal/transitions/entrance",
"js/cordova",
"js/facebookscript",
"lib/bootstrap/bootstrap",
"lib/bootstrap/bootstrap.min",
"lib/breeze/breeze.debug",
"lib/breeze/breeze.intellisense",
"lib/breeze/breeze.min",
"lib/breeze/q",
"lib/breeze/q.min",
"lib/jquery/jquery-2.0.3.intellisense",
"lib/jquery/jquery-2.0.3",
"lib/jquery/jquery-2.0.3.min",
"lib/knockout/knockout-2.3.0.debug",
"lib/knockout/knockout-2.3.0",
"lib/knockout/knockout.mapping-latest.debug",
"lib/knockout/knockout.mapping-latest",
"lib/knockout/knockout.validation.debug",
"lib/knockout/knockout.validation",
"lib/moment/moment",
"lib/moment/moment.min",
"lib/ratchet/ratchet",
"lib/sammy/sammy-0.7.4",
"lib/sammy/sammy-0.7.4.min",
"lib/toastr/toastr",
"lib/toastr/toastr.min"
],
"exclude": [],
"keepBuildDir": true,
"optimize": "uglify2",
"out": "C:\\DNNDev.me\\DesktopModules\\Framework.App\\App\\main-built.js",
"pragmas": {
"build": true
},
"wrap": true,
"insertRequire": [
"main"
]
}
答案 0 :(得分:0)
在你的路径中,你设置的knockout的引用等于映射插件,这不是bueno。
如本回答所示,Durandal.js optimizer not working (empty main-built.js)您可以像Rainer演示一样运行它,您应该会看到更具体的错误。
我发现了一件事 - 如果您删除视图模型或使用文件夹或目录作为炼狱(即将被删除),那些文件可能不会在您的应用中使用,但如果它们在文件结构中,它们仍然会由优化器评估。
修改强>
点击此处查看有关优化工具的更多信息 - Tracking down optimizer issues in durandal.js
另外,您正在构建调试版还是发布版?你的目标是正确的吗? durandal optimizer references wrong path when building it as a post build process in Visual Studio
另外,如果您正在引用Knockout.js,我认为您的意思是引用“lib / knockout / knockout-2.3.0”而不是淘汰映射插件。
除非我遗漏了某些内容,否则您不必将这些路径添加到main.js文件中。应该引用Breeze和Knockout。根据您的项目类型,编辑器等...它可能捆绑在DurandalBundleConfig下的App.Start文件夹中。如果不是,那么您只是引用index.html中的库吗?
如果是这种情况(如下所示),将它们移动到捆绑配置中 -
bundles.Add(
new ScriptBundle("~/scripts/vendor")
.Include("~/Scripts/jquery-{version}.js")
.Include("~/Scripts/jquery-ui-{version}.min.js")
.Include("~/Scripts/knockout-{version}.js")
.Include("~/Scripts/sammy-{version}.js")
.Include("~/Scripts/bootstrap.min.js")
.Include("~/Scripts/knockout-bootstrap.min.js")
.Include("~/Scripts/Q.js")
.Include("~/Scripts/breeze.debug.js")
);
请注意,您需要在Breeze之前加载Q,因为Breeze依赖于Q.