SassNinja / media-query-plugin

Webpack plugin for media query extraction.
MIT License
205 stars 27 forks source link

include parameter not work with RegExp #16

Closed hotsanchous closed 5 years ago

hotsanchous commented 5 years ago

Hi.

I have nodejs v11.12.0, npm 6.9.0 and webpack v4.29.6 When i set RegExp to parameter include, i see an errors.

I watch src of Loader, and find this code // check if current file should be affected if (typeof options.include === 'object' && options.include.indexOf(options.basename) > -1) { isIncluded = true; } else if (options.include instanceof RegExp && options.basename.match(options.include)) { isIncluded = true; } else if (options.include === true) { isIncluded = true; }

If inside include RegExp, typeof return 'object' and options.include.indexOf(options.basename) gives an error.

SassNinja commented 5 years ago

Hi @hotsanchous

thanks for your report!

You're right that's definitely a bug. The condition doesn't consider RegExp has also typeof object. I'll fix it.