Home > database >  Export webpack function in typescript
Export webpack function in typescript

Time:11-05

The webpack docs show the type to be return from configuration function, but not the types of the parameters env and argv. Currently I've to type them as any, however what are the actual types of env and argv?

const configuration = (env: any, argv: any): Configuration => ({
  mode: 'production',
  entry: './foo.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'foo.bundle.js',
  },
  ...
});

CodePudding user response:

They are both any because they are both coming from the webpack cli arguments, so it is not possible to know the type in advance at compile time (unless you strictly know that you will always pass certain arguments and force the type to be what you declare it to be)

Webpack Environment Variables docs may help to understand better.

  • Related