【问题标题】:RequireJs optimizer ignore pluginRequireJs 优化器忽略插件
【发布时间】:2012-10-23 01:09:18
【问题描述】:
我想在使用优化器时忽略 require js 插件的使用
define(["css!styles.css"])
这总是给我这个错误
Cannot read property 'normalize' of undefined.
我已将此选项设置为 require 优化器
{
paths : {
'css' : 'empty:'
}
}
但它一直给我错误。
【问题讨论】:
标签:
javascript
requirejs
require
js-amd
【解决方案1】:
我不知道这是否是你想要的,但你可以去掉 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