-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2903a2e
commit 198091c
Showing
7 changed files
with
110 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"plugins": [ | ||
[ | ||
"module-resolver", | ||
{ | ||
"root": ["."], | ||
"alias": { | ||
"@assets": "./src/assets" | ||
} | ||
} | ||
] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Module Resolver handbook | ||
|
||
[offical babel-plugin-module-resolver](https://yarnpkg.com/package/babel-plugin-module-resolver) | ||
|
||
#### Install Module Resolver package in the project | ||
|
||
```bash | ||
$ yarn add -D babel-plugin-module-resolver | ||
``` | ||
|
||
##### 1. Create jsconfig.json for VS Code Configure the path mapping | ||
|
||
```json | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"paths": { | ||
"@assets": ["./src/assets"] | ||
} | ||
} | ||
} | ||
``` | ||
|
||
##### 2. Specify the plugin in your .babelrc with the custom root or alias. | ||
|
||
``` | ||
{ | ||
"plugins": [ | ||
[ | ||
"module-resolver", | ||
{ | ||
"root": ["."], | ||
"alias": { | ||
"@assets": "./src/assets", | ||
} | ||
} | ||
] | ||
] | ||
} | ||
``` | ||
|
||
### Usage | ||
|
||
```js | ||
import { Assets } from "@assets"; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"paths": { | ||
"@assets": ["./src/assets"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters