RequireJs optimizer ignore plugin

对着背影说爱祢 提交于 2019-12-23 13:01:10

问题


I would like to ignore the use of a require js plugin when I use the optimizer

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

This always gives me this error Cannot read property 'normalize' of undefined.

I've set this options to the require optimizer

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

But it keeps giving me the error.


回答1:


I don't know if that is what you want, but you could stub out the css plugin.

//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'],

So in your case:

stubModules: ['css']

More details, see Requirejs Optimizer Config options



来源:https://stackoverflow.com/questions/13194147/requirejs-optimizer-ignore-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!