RequireJs优化器忽略插件 [英] RequireJs optimizer ignore plugin

查看:139
本文介绍了RequireJs优化器忽略插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用优化程序时,我想忽略对require js插件的使用

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

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

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

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

我已将此选项设置为require优化器

I've set this options to the require optimizer

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

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

但是它总是给我错误.

推荐答案

我不知道这是否是您想要的,但是您可以将css插件存根.

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

所以在您的情况下:

stubModules: ['css']

更多详细信息,请参见 Requirejs Optimizer Config选项

More details, see Requirejs Optimizer Config options

这篇关于RequireJs优化器忽略插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆