RequireJs优化器忽略插件

时间:2012-11-02 11:16:42

标签: javascript requirejs require js-amd

当我使用优化器

时,我想忽略使用require js插件

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

这总是给我这个错误 Cannot read property 'normalize' of undefined

我已将此选项设置为require optimizer

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

但它一直给我错误。

1 个答案:

答案 0 :(得分: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