2013-10-11 46 views
2

我有一個使用通過require.js +文本插件underscore.js模板和加載它們的應用程序:從requirejs優化剔除模板

define([..., 'text!templates/app/authentication.html'], function(..., Template) { 
... 
}); 

所有工作正常,但現在我要來連接我所有的js文件到Grunt.js和require.js優化器。以下是繁重的文件的相應部分:

requirejs: { 
    compile: { 
     options: { 
      name : 'main', 
      baseUrl: "www/js", 
      optimize: "none", 
      out: "www/js/result.js", 
      stubModules : ['text'], 
      paths : { 
       text: 'vendor/text', 
       ... 
      }, 

      shim: { 
       ... 
      } 
     } 
    } 
} 

但咕嚕拋出我的下一個錯誤:

Running "requirejs:compile" (requirejs) task 
>> Tracing dependencies for: nexusapp 
>> Error: ENOENT, no such file or directory 
>> 'D:\templates\app\authentication.html' 
>> In module tree: 
>>  main 
>>  app 
>>   app.authentication 
>>   text 
Warning: RequireJS failed. Use --force to continue. 

Aborted due to warnings. 

優化試圖讀取文件忽略指定baseUrl。 我該如何解決這個問題?

預先感謝您!

回答

0

我知道,要從RequireJS編譯中排除某個模塊,您需要在配置文件中爲其路徑指定'空:'。像這樣:

{ 
    ... 
    ... 
    paths: { 
      'module_you_want_1': '/path/to/module/you/want/1', 
      'module_you_want_2': '/path/to/module/you/want/2', 
      'module_you_dont_want': 'empty:' 
     }, 
    ... 
    ... 
}