-
Notifications
You must be signed in to change notification settings - Fork 8
Creating path aliases
Wojtek Cichoń edited this page Jan 25, 2021
·
2 revisions
In order to create an import alias for a path you need to do the following.
{
"compilerOptions": {
"paths": {
"MyPath/*": ["src/my-path/*"]
}
}
}
// webpack/paths.js
module.exports = {
myPath: "./src/my-path"
}
// webpack/resolve.js
module.exports = {
resolve: {
alias: {
MyPath: path.resolve(__dirname, "..", paths.myPath),
},
},
}
module.exports = {
moduleNameMapper: {
"MyPath/(.*)": "<rootDir>/src/my-path/$1",
}
}