当前位置:网站首页>配置@路径简化路径处理
配置@路径简化路径处理
2022-08-11 05:17:00 【-加油】
1、安装修改 CRA 配置的包:yarn add -D @craco/craco
2、在项目根目录中创建 craco 的配置文件:craco.config.js,并在配置文件中配置路径别名
craco.config.js:
const path = require('path')
module.exports = {
// webpack 配置
webpack: {
// 配置别名
alias: {
// 约定:使用 @ 表示 src 文件所在路径
'@': path.resolve(__dirname, 'src')
}
}
}
3、修改 package.json 中的脚本命令。
package.json中的"scripts":全覆盖了
// 将 start/build/test 三个命令修改为 craco 方式
"scripts": {
"start": "craco start",
"build": "craco build",
"test": "craco test",
"eject": "react-scripts eject"
}
在代码中,就可以通过 @ 来表示 src 目录的绝对路径。
4、重启项目,让配置生效
npm start
或者
yarn start
@别名路径提示:能够让vscode识别@路径并给出路径提示
在项目根目录创建 jsconfig.json 配置文件
{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@/*": ["src/*"]
}
}
}
边栏推荐
猜你喜欢

一、Jmeter环境部署

(2) Construction of a real-time performance monitoring platform (Grafana+Prometheus+Jmeter)

【转载】CMake 语法 - 详解 CMakeLists.txt

(2) Docker installs Redis in practice (persistent AOF and RDB snapshots)

【win10+cuda7.5+cudnn6.0安装caffe①】安装cuda和cudnn

C语言自定义数据类型——联合体

软件测试风险识别

C语言结构体详解 (2) 结构体内存对齐,默认对齐数

C语言——文件操作详解(1)

Summary: Cross Validation
随机推荐
C语言文件操作——数据文件类型、文件判断、文件缓冲区详解
第13章类继承
Chapter 13 Class Inheritance
(3) Construction of a real-time performance monitoring platform (Grafana+Prometheus+Node_explorer+Jmeter)
吃瓜教程task05 第6章 支持向量机
【备忘】从零开始搭建Yolo5训练环境
2021研究生数学建模D题,BP神经网络和卷积神经网络解题代码(基于pytorch)
数组的用法
做款好喝的茶饮~
组件间通信
Blender 初教程
第10章 对象和类 -1
第9章 内存模型和名称空间
leetcode21. Merge two ordered linked lists
【分享】一个免费语料库
C - file operations fseek () function, ftell, rewind, rounding
labelme工具,对类别标注,再进行细致的分割
C语言结构体——位段概念的讲解
C language file operation - detailed explanation of data file type, file judgment, and file buffer
LeetCode1166. Designing File Systems