0

I have used resolveExtensions in webpack config as follows.

const commonOpts = {
  isExternalEnv: true,
  outputPath: 'dist/production/www',
  resolveExtensions: ['.js', '.ts', '.json', '.jsx', '.scss']
}

It is working fine for normal components.

As i am using module federation concepts in project. So i am exposing components like below for which resolveExtensions configuration is not working.

const commonOpts = {
  isExternalEnv: true,
  outputPath: 'dist/production/www',
  resolveExtensions: ['.js', '.ts', '.json', '.jsx', '.scss'],
  module: {
    rules: [
        {
            test: /\.(sa|sc|c)ss$/,
            use: [
                {
                    loader: 'sass-resources-loader',
                    options: {
                        resources: require('./src/styles/common/index.js'),
                    },
                },
            ],
        },
    ],
  },
  moduleFederationOpts: {
    name: 'MyApp',
    filename: 'js/my-app-entry.js',
    exposes: {
        './myapp': './src/app.js',
        './myAppBlock': './src/modules/blocks/myBlock.js',
    },
  },
}

How can we apply resolveExtensions configuration to exposed components?

1 Answer 1

0

If you using Webpack 5. Try this!

 resolve: {
    extensions: ['*', '.js', '.ts', '.json', '.jsx', '.scss'],
    ...
}
1
  • Yes. But it's not working for exposes components. Commented Dec 25, 2023 at 8:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.