Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpack相关 #16

Open
buddywang opened this issue Oct 13, 2020 · 0 comments
Open

webpack相关 #16

buddywang opened this issue Oct 13, 2020 · 0 comments
Labels

Comments

@buddywang
Copy link
Owner

配置之 Resolve

该选项用来改变模块是怎么被解析的

module.exports = {
  //...
  resolve: {
    // configuration options
  }
}

resolve.alias

创建别名让导入某些模块更加简短(相当于一个字符串变量,编译时替换)

const path = require('path');

module.exports = {
  //...
  resolve: {
    alias: {
      'Util': path.resolve(__dirname, 'src/utilities/')
    }
  }
};

原来的导入

import Utility from '../../utilities/utility';

可以简单用以下表示,注意路径

import Utility from 'Util/utility';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant