[英]Marionette Modules missing after minifying the files through grunt
I'm using Backbonejs with RequirejS to create an application and used Grunt as a build tool. 我将Backbonejs与RequirejS一起使用来创建应用程序,并使用Grunt作为构建工具。 Minified files were generated using grunt task "grunt-requirejs". 使用grunt任务“ grunt-requirejs”生成了缩小的文件。
After that I implemented MarionetteJs for using the marionette modules and after implementing marionette modules in the application, the problem started occurring in Grunt build process. 之后,我实现了使用Marionette模块的MarionetteJs,并在应用程序中实现了Marionette模块之后,在Grunt构建过程中开始出现问题。 When i'm running the application with minified file, i'm getting error 当我运行带有缩小文件的应用程序时,出现错误
"uncaught Error: undefined missing modules/main/mainApp"
mainApp.js is my main module which would govern the other modules. mainApp.js是我的主模块,它将管理其他模块。
Code snippet app.js - 代码段app.js-
define([ 'marionette' ], function(Marionette) {
var MainApplication = new Marionette.Application();
MainApplication.on("start", function(){
if(Backbone.history){
require(['modules/main/mainApp'], function (MainApp) {
Backbone.history.start();
MainApp.start();
});
}
});
return MainApplication;
}
I googled a lot about this question but couldn't find a concrete solution. 我在这个问题上搜索了很多,但是找不到具体的解决方案。
Do i have to include any other task for minifying the marionette files? 我是否必须包括其他任务以缩小木偶文件?
Also i came up with this blogpost , which confuses whether to used Requirejs with Marionette modules. 我也想出了这个博客文章 ,该文章混淆了是否将Requirejs与Marionette模块一起使用。
Any suggestions/approach for checking the marionette files are minified and are working correctly would be really helpful. 用于检查木偶文件的任何建议/方法都应缩小,并且可以正常工作,这将非常有帮助。
Edit: Added code snippet. 编辑:添加了代码段。
I got the solution. 我找到了解决方案。 It was just simply adding one more option to the optimization task. 只是在优化任务中增加了一个选项。
In my grunt task 在我艰苦的任务中
requirejs: {
compile: {
options: {
findNestedDependencies: true,
// Edited for brevity
}
}
},
I added findeNestedDependencies : true
and it actually picked up the nested dependencies. 我添加了findeNestedDependencies : true
,它实际上拾取了嵌套的依赖项。 I got the reference from David Sulc's book for RequireJS, BackboneJS and Marionette. 我从David Sulc的书中获得了RequireJS,BackboneJS和Marionette的参考。 In this book he was optimizing the application with RequireJS optimizer and then i found that attribute in the build.js file. 在这本书中,他使用RequireJS优化器优化了应用程序,然后我在build.js文件中找到了该属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.