1

I need to run Webpack on some arbitrary directory. That directory contains only some TypeScript source code, but not the loaders used in my Webpack configuration. So I have this:

webpack({
    context: "/some/arbitrary/directory",
    ..., // Some more options here
    module: {
        rules: [
            {
                test: /\.(ts|js)x?$/,
                exclude: /node_modules/,
                use: {
                    loader: "babel-loader",

However, that causes Webpack to look for the babel-loader in the same directory as context (/some/arbitrary/directory). That behavior is also documented here: https://webpack.js.org/configuration/entry-context/#context.

How can I specify that loaders should be loaded from a different directory? Or is it simply impossible?

My only hope now is to manipulate the inputFileSystem option using linkfs or some other nasty hack :-(

HelloWorld
  • 3,381
  • 5
  • 32
  • 58

0 Answers0