score:0

webpack provides a module resolve functionality that you can use here. read the docs here. as an example, in your case, you can do this:

const path = require('path');

module.exports = {
  resolve: {
    alias: {
      '@/components/module1': path.join(
        __dirname,
        process.env.app_brand
          ? '@/components/brands/' + process.env.app_brand + 'module1'
          : '@/components/module1')
    }
  },
};

note that, here you would pass environment variable to your webpack process (aka node.js process) and make decision accordingly. also, your resolve module must be absolute path.


Related Query

More Query from same tag