Gathering detailed insights and metrics for craco-alias
Gathering detailed insights and metrics for craco-alias
Gathering detailed insights and metrics for craco-alias
Gathering detailed insights and metrics for craco-alias
A craco plugin for automatic aliases generation for Webpack and Jest
npm install craco-alias
Typescript
Module System
Node Version
NPM Version
JavaScript (99.75%)
Shell (0.25%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
109 Stars
76 Commits
11 Forks
3 Watchers
6 Branches
4 Contributors
Updated on Mar 03, 2024
Latest Version
3.0.1
Package Id
craco-alias@3.0.1
Unpacked Size
37.44 kB
Size
9.76 kB
File Count
40
NPM Version
6.14.12
Node Version
12.22.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
A craco plugin for automatic aliases generation for Webpack and Jest.
Install craco
Install craco-alias
:
1npm i -D craco-alias
1yarn add -D craco-alias
Edit craco.config.js
:
1const CracoAlias = require("craco-alias"); 2 3module.exports = { 4 plugins: [ 5 { 6 plugin: CracoAlias, 7 options: { 8 // see in examples section 9 } 10 } 11 ] 12};
Go to Examples section
source
:
One of "options"
, "jsconfig"
, "tsconfig"
Optional, defaults to "options"
baseUrl
:
A base url for aliases. (./src
for example)
Optional, defaults to ./
(project root directory)
aliases
:
An object with aliases names and paths
Only required when source
is set to "options"
tsConfigPath
:
A path to tsconfig file
Only required when source
is set to "tsconfig"
filter
:
A function of type ([key, value]) => boolean
Optional, used to remove some aliases from the resulting config
Example: ([key]) => !key.startsWith('node_modules')
unsafeAllowModulesOutsideOfSrc
:
Allow importing modules outside of ./src
folder.
Disables webpack ModuleScopePlugin
.
debug
:
Enable it if you ran into a problem. It will log a useful info in console.
Optional, defaults to false
Note: you don't need to add
/*
part for directories in this case
1/* craco.config.js */ 2 3const CracoAlias = require("craco-alias"); 4 5module.exports = { 6 plugins: [ 7 { 8 plugin: CracoAlias, 9 options: { 10 source: "options", 11 baseUrl: "./", 12 aliases: { 13 "@file": "./src/file.js", 14 "@dir": "./src/some/dir", 15 // you can alias packages too 16 "@material-ui": "./node_modules/@material-ui-ie10" 17 } 18 } 19 } 20 ] 21};
1/* craco.config.js */ 2 3const CracoAlias = require("craco-alias"); 4 5module.exports = { 6 plugins: [ 7 { 8 plugin: CracoAlias, 9 options: { 10 source: "jsconfig", 11 // baseUrl SHOULD be specified 12 // plugin does not take it from jsconfig 13 baseUrl: "./src" 14 } 15 } 16 ] 17};
Note: your jsconfig should always have
compilerOptions.paths
property.baseUrl
is optional for plugin, but some IDEs and editors require it for intellisense.
1/* jsconfig.json */ 2 3{ 4 "compilerOptions": { 5 "baseUrl": "./src", 6 "paths": { 7 // file aliases 8 "@baz": ["./baz.js"], 9 "@boo": ["./boo.jsx"], 10 11 // folder aliases 12 "@root": ["./"], 13 "@root/*": ["./*"], 14 "@lib": ["./lib"], 15 "@lib/*": ["./lib/*"], 16 17 // package aliases (types is optional without ts) 18 "@my-react-select": [ 19 "../node_modules/react-select", 20 "../node_modules/@types/react-select" 21 ], 22 "@my-react-select/*": [ 23 "../node_modules/react-select/*", 24 "../node_modules/@types/react-select" 25 ] 26 } 27 } 28}
Go to project's root directory.
Create tsconfig.extend.json
.
Edit it as follows:
1{ 2 "compilerOptions": { 3 "baseUrl": "./src", 4 "paths": { 5 // file aliases 6 "@baz": ["./baz.ts"], 7 "@boo": ["./boo.tsx"], 8 9 // folder aliases 10 "@root": ["./"], 11 "@root/*": ["./*"], 12 "@lib": ["./lib"], 13 "@lib/*": ["./lib/*"], 14 15 // package aliases 16 "@my-react-select": [ 17 "../node_modules/react-select", 18 "../node_modules/@types/react-select" 19 ], 20 "@my-react-select/*": [ 21 "../node_modules/react-select/*", 22 "../node_modules/@types/react-select" 23 ] 24 } 25 } 26}
Go to tsconfig.json
.
Extend tsconfig.json
from tsconfig.extend.json
:
1{ 2+ "extends": "./tsconfig.extend.json", 3 "compilerOptions": { 4 ... 5 }, 6 ... 7}
Edit craco.config.js
:
1const CracoAlias = require("craco-alias"); 2 3module.exports = { 4 plugins: [ 5 { 6 plugin: CracoAlias, 7 options: { 8 source: "tsconfig", 9 // baseUrl SHOULD be specified 10 // plugin does not take it from tsconfig 11 baseUrl: "./src", 12 // tsConfigPath should point to the file where "baseUrl" and "paths" are specified 13 tsConfigPath: "./tsconfig.extend.json" 14 } 15 } 16 ] 17};
Make sure your config is valid.
Set debug
to true
in options.
Run application again.
Copy a printed info.
Here, create an issue describing your problem (do not forget to add the debug info).
Install:
1yarn
Use yarn please. npm may fail the dependencies installation.
Run tests:
yarn test
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 3/25 approved changesets -- score normalized to 1
Reason
project is archived
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
22 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More