解决react项目引入antd-mobile导致配置文件别名失效问题

今天使用了一下antd-mobile发现我之前配置的文件别名都失效了,防止下次踩坑记录一下解决方案
解决react项目引入antd-mobile导致配置文件别名失效问题_第1张图片

打开根目录下的config-overrides.js文件在该文件下重新配置以下别名

const {
     
  override,
  fixBabelImports,
  addWebpackAlias,
} = require("customize-cra");
const path = require("path");
module.exports = override(
  // 配置按需加载
  fixBabelImports("import", {
     
    libraryName: "antd-mobile",
    style: "css",
  }),
  // 配置文件别名
  addWebpackAlias({
     
    "@": path.resolve(__dirname, "src"),
    "@scss": path.resolve(__dirname, "src/assets/scss"),
    "@images": path.resolve(__dirname, "src/assets/images"),
    "@views": path.resolve(__dirname, "src/views"),
    "@network": path.resolve(__dirname, "src/network"),
    "@store": path.resolve(__dirname, "src/store"),
    "@components": path.resolve(__dirname, "src/components"),
  })
);

你可能感兴趣的:(react,javascript,react,javascript)