RequireJs optimizer ignore plugin

2019-06-25 04:38发布

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条回答
对你真心纯属浪费
2楼-- · 2019-06-25 05:12

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

查看更多
登录 后发表回答