trayio / babel-plugin-webpack-alias

babel 6 plugin which allows to use webpack resolve options
MIT License
150 stars 32 forks source link

Support resolveLoader.alias #55

Open mhuggins opened 6 years ago

mhuggins commented 6 years ago

I'm trying to change a resolver for a test. Specifically, I have a file being required via "worker-loader?inline=true!pdfjs-dist/build/pdf\.worker", and I would like my test suite to treat it as "raw-loader!pdfjs-dist/build/pdf\.worker".

I tried to abuse the current setup like so:

resolve: {
  alias: {
    "worker-loader\\?inline=true!pdfjs-dist/build/pdf\\.worker": path.resolve(__dirname, "node_modules/pdfjs-dist/build/pdf.worker.js")
  }
}

Unfortunately, that simply prefixes the import with "./", changing it into "./worker-loader?inline=true!pdfjs-dist/build/pdf\.worker".

mhuggins commented 6 years ago

Also a minor thing, but if a filename has a "." in it, your regexp match will treat that as any character instead of a period.