create-react-app 脚手架,让react引入 @指向src(zhuan)

一、先暴露出webpack等相关配置文件

npm run eject

二、修改 config/webpack.config.js 文件配置

const paths = require('./paths'); // config 中的一个文件

resolve: {
	...
  alias: {
  	...
    '@': paths.appSrc, // 增加这里
  }
}

三、引用
例:src / laylout / index.js 文件

import Header from ''@/components/Header;

posted @ 2021-10-22 11:27  雪莉06  阅读(209)  评论(0)    收藏  举报