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.
            Asked
            
        
        
            Active
            
        
            Viewed 83 times
        
    0
            
            
         
    
    
        Alex99
        
- 3
- 2
1 Answers
0
            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/')
    }
  }
};
 
    
    
        dunhuang
        
- 331
- 2
- 5
- 
                    Thatnks for the answer! I followed your advice, but there's the mistake: Module not found: You attempted to import E:\Repo\pb.screen\pb\scr\ss\js\Controls/example which falls outside of the project src/ directory. Relative imports outside of src/ are not supported. – Alex99 Jul 26 '20 at 13:39
- 
                    So, the file where I need do the import is located in: E:\Repo\pb.screen\pb\scr\ss\js\Views\MenuPage\Menu.js – Alex99 Jul 26 '20 at 13:45
- 
                    if you are using creat-react-app, try to follow it's instruction, cause it has some custom config. https://stackoverflow.com/questions/44114436/the-create-react-app-imports-restriction-outside-of-src-directory/44115058 – dunhuang Jul 26 '20 at 13:59
- 
                    dunhuang, thanks a lot!! Your advice helped me, I added resole.alias in the wrong place the first time, but it works – Alex99 Jul 26 '20 at 21:06
- 
                    glad that’s help – dunhuang Jul 27 '20 at 02:06