当前位置:网站首页>Use @ in the project created by CRA, let it recognize the @ path and give path tips
Use @ in the project created by CRA, let it recognize the @ path and give path tips
2022-07-27 17:25:00 【Mr_ ZCheng】
1.vscode distinguish @ Path and give path prompt
- Create in project root
jsconfig.jsonThe configuration file - Add the following configuration... To the configuration file
jsconfig.json in :
{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@/*": ["src/*"]
}
}
} After the above operation ,VSCode Will automatically read jsconfig.json Configuration in , Give Way vscode know @ Namely src Catalog
2. To configure @ path alias , Allow scaffolding tools to identify @
CRA(create-react-app) Put all engineering configurations , It's all hidden in react-scripts In bag , therefore , No configuration information or configuration files can be seen in the project .
If you want to modify CRA Default configuration , There are several options :
- 【 recommend 】 Modify... Through a third-party library , such as ,
@craco/craco - Through execution
yarn ejectcommand , Releasereact-scriptsAll configurations in the are added to the project ( Be careful : The operation is irreversible !!!
craco How to use
Installation package .
npm i -D @craco/craco- Under the project root , create profile :
craco.config.js. You can make custom modifications in the configuration file .
craco.config.js Configure path aliases
const path = require('path')
module.exports = {
webpack: {
alias: {
'@': path.join(__dirname, 'src')
}
}
}3. modify package.json Script command in
package.json in :
// take start/build/test The three commands are changed to craco The way
"scripts": {
"start": "craco start",
"build": "craco build",
"test": "craco test",
"eject": "react-scripts eject"
},4. In the code , You can go through @ To express src The absolute path to the directory
5. Restart project , Make the configuration work
边栏推荐
- MySQL : 函数
- Uncle's nephew and his students
- 高精度定时器
- Behind every piece of information you collect, you can't live without TA
- Passive income: return to the original and safe two ways to earn
- CUE语言基础入门:CUE是一门为配置而生的语言
- 动作捕捉系统用于柔性机械臂的末端定位控制
- Niuke topic - the minimum number of K
- 诸神黄昏,“猫抖快”告别大V时代
- Three table joint query 2
猜你喜欢

Can deep learning overturn video codec? The first prize winner of the National Technological Invention Award nags you in the little red book

Design details of hidden iframe and form elements used by SAP ui5 fileuploader

.net core with microservices - what is a microservice

Neural network implementation of handwritten numeral classification matlab

Gradient ring progress bar

Two table joint query 1

Flex弹性盒布局2

Hegong sky team vision training Day7 - vision, Jetson naon and d435i

The 7-year-old boy broke his finger by AI robot just because he played chess too fast?

With the arrival of large displacement hard core products, can the tank brand break through the ceiling of its own brand?
随机推荐
Flex弹性盒布局2
WebView basic use
今日睡眠质量记录82分
小于n的最大数
阿里巴巴鹰眼系统简介
Introduction to Alibaba eagle eye system
Kubernetes Part 7: using kubernetes to deploy prometheus+grafana monitoring system (kubernetes work practice class)
Niuke topic -- binary search tree and bidirectional linked list
KMP template - string matching
How does vs2019 C language run multiple projects at the same time, how to add multiple source files containing main functions in a project and debug and run them respectively
Shell programming specifications and variables
High precision timer
day07 作业
信号量保护之位带操作
交换机和路由器技术-03-交换机基本配置
关于 SAP UI5 应用 ui5.yaml 里的 paths 映射问题
立创EDA——原理图的布局与检查(三)
Kubernetes第七篇:使用kubernetes部署prometheus+grafana监控系统(Kubernetes工作实践类)
Swift QQ授权登录 坑集
Bit band operation of semaphore protection