1

我正在尝试优化我的 Durandal 应用程序,但 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"
  ]
}
4

1 回答 1

0

在您的路径中,您将对淘汰赛的引用设置为等于映射插件,这不是 bueno。

如这个答案所示,Durandal.js 优化器不工作(空的 main-built.js)你可以像 Rainer 展示的那样运行它,你应该会看到一个更具体的错误。

我发现的一件事 - 如果您删除视图模型或使用文件夹或目录作为炼狱(即将被删除),这些文件可能不会在您的应用程序中使用,但如果它们在文件结构中,它们仍将被评估优化器。

编辑

在此处查看有关优化器的更多信息 -在 durandal.js 中跟踪优化器问题

另外,您是在构建调试还是发布?你的目标是正确的吗? durandal 优化器在 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。

于 2013-07-30T14:36:40.817 回答