Search code examples
javascriptreactjsimportcore-js

How to reduce upward import with core-js?


I need to do import from a file that is in an another directive, so I go "up" with import from '../../../Controls/example' I know that it can be reduced with core-js to something like import from 'Controls/example', but I can't get how.


Solution

  • Do you mean give a short alias name of local files? You can add resolve.alias config in webpack.config.js

    const path = require('path');
    
    module.exports = {
      //...
      resolve: {
        alias: {
          Controls: path.resolve(__dirname, '../../../Controls/')
        }
      }
    };
    

    https://webpack.js.org/configuration/resolve/#resolvealias