How to describe types for webpack config exporting as a function from .ts file?

Viewed 118

I use webpack config as a function with webpack-merge

export default (env) => {
  // working with env data

  return mergeWithRules({
        module: {
            rules: {
                test: CustomizeRule.Match,
                use: {
                    loader: CustomizeRule.Match,
                    options: CustomizeRule.Merge,
                },
            },
        },
    })(baseConfig, {
         // webpack options
         output: {
            path: path.resolve(__dirname, '..', './dist', isLegacy ? 'legacy' : 'modern'),
            publicPath: '/',
            // TODO: FIX ME. Type is missing
            filename: (pathData: any) => {
                return pathData.chunk.name === workerName ? '[name].js' : `[name].[fullhash].js`;
            },
            chunkFilename: '[id].[fullhash].js',
            globalObject: 'this',
        },
      })
}

Problem is missing types in webpack options from a merging object. How can I merge them correctly with correct types and avoid any types?

0 Answers
Related