2012-11-02 90 views
3

我想忽略使用要求JS插件的時候我用的是優化RequireJs優化忽略插件

define(["css!styles.css"])

這總是給我這個錯誤 Cannot read property 'normalize' of undefined

我已經設置這個選項給需要優化

{ paths : { 'css' : 'empty:' } }

但它不斷給我的錯誤。

回答

0

我不知道這是你想要的,但你可以將css插件存根。

//Specify modules to stub out in the optimized file. The optimizer will 
//use the source version of these modules for dependency tracing and for 
//plugin use, but when writing the text into an optimized bundle, these 
//modules will get the following text instead: 
//If the module is used as a plugin: 
// define({load: function(id){throw new Error("Dynamic load not allowed: " + id);}}); 
//If just a plain module: 
// define({}); 
//This is useful particularly for plugins that inline all their resources 
//and use the default module resolution behavior (do *not* implement the 
//normalize() method). In those cases, an AMD loader just needs to know 
//that the module has a definition. These small stubs can be used instead of 
//including the full source for a plugin. 
stubModules: ['text', 'bar'], 
你的情況

所以:

stubModules: ['css'] 

更多詳細信息,請參閱Requirejs Optimizer Config options