Skip to content

Commit 3735812

Browse files
committed
refactor: Configuring absolute imports because relative one sucks
1 parent b922f7f commit 3735812

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

.storybook/webpack.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
const path = require('path')
2+
const rootDir = path.resolve(__dirname, '..')
3+
14
module.exports = ({ config }) => {
25
// Enable typescript support
36
config.module.rules.push({
@@ -18,6 +21,10 @@ module.exports = ({ config }) => {
1821
]
1922
})
2023

24+
config.resolve.alias = Object.assign(config.resolve.alias, {
25+
'@src': path.resolve(rootDir, 'src')
26+
})
27+
2128
config.node = {
2229
__dirname: true
2330
}

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@
6767
"moduleFileExtensions": [
6868
"ts",
6969
"js"
70-
]
70+
],
71+
"moduleNameMapper": {
72+
"^@src/(.*)$": "<rootDir>/$1"
73+
}
7174
},
7275
"prettier": {
7376
"semi": false,

tsconfig.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
"emitDecoratorMetadata": true,
1414
"declarationDir": "dist/types",
1515
"outDir": "dist/lib",
16-
"typeRoots": ["node_modules/@types"]
16+
"typeRoots": ["node_modules/@types"],
17+
"baseUrl": ".",
18+
"paths": {
19+
"@src/*": ["./src/*"]
20+
}
1721
},
1822
"include": ["src"]
1923
}

0 commit comments

Comments
 (0)