nippur72/ifdef-loader

use loader-utils to get options

Closed this issue · 0 comments

HI,

Nice idea.

You are forcing the users to use a query string to provide options to the loader.

Webpack loader configuration comes with support for setting options either by

  • Options object
  • query string

Webpack has a best practice and tooling for that, so you don't care how the user provided the options, you just get them:

Instead of querystring install loader-utils, then:

const loaderUtils = require('loader-utils');

function loader() {
  const options = loaderUtils.getOptions(this);
}

Now you have the options ready for you.

This is also future proof, using that util will ensure that if webpack changes the way options are defined it will still work for you.