{
  "path": "/posts/webpack-resolveloader-alias-with-query",
  "site": "at://did:plc:yy3apqjlms24kso7ahn7lbmb/site.standard.publication/3mova7c4nho2b",
  "tags": [
    "webpack"
  ],
  "$type": "site.standard.document",
  "title": "webpack: resolveLoader / alias with query / options",
  "description": "Webpacks enhanced-resolve has a bug with aliased loaders. A workaround involves suffixing the aliased path with query options.",
  "publishedAt": "2017-01-06T00:00:00.000Z",
  "textContent": "Sometimes you write a post for the ages. Sometimes you write one you hope is out of date before you hit \"publish\". This is one of those.\n\n\n\nThere's a bug in webpack's enhanced-resolve. It means that you cannot configure an aliased loader using the query (or options in the webpack 2 nomenclature). Let me illustrate; consider the following code:\n\nAt the time of writing, if you alias a loader as above, then the query / options will \\_not_\\ be passed along. This is bad, particularly given the requirement in webpack 2 that configuration is no longer possible through extending the webpack.config.js. So what to do? Well, when this was a problem previously the marvellous James Brantly had a workaround. I've taken that and run with it:\n\nThis approach stringifies the query / options and suffixes it to the aliased path. This works as long as the options you're passing are JSON-able (yes it's a word).\n\nAs I said earlier; hopefully by the time you read this the workaround will no longer be necessary again. But just in case....",
  "canonicalUrl": "https://johnnyreilly.com/posts/webpack-resolveloader-alias-with-query"
}