当前位置:网站首页>Alias the path with the help of craco

Alias the path with the help of craco

2022-06-11 06:21:00 Geek student

React Alias the path in With the help of craco Realization .

craco.config.json


const path = require("path");
const resolve = dir => path.resolve(__dirname, dir);

module.exports = {
    
.....
  webpack: {
    
    alias: {
    
      "@": resolve("src"),
      "components": resolve("src/components")
    }
  }
}

Import

import Header from '@/components/Header';
import Header from 'components/Header';
原网站

版权声明
本文为[Geek student]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020527521335.html