Last active
December 18, 2019 08:15
-
-
Save forabi/55a939ccbf82c9963ab54a369ad95bc7 to your computer and use it in GitHub Desktop.
Configuring Webpack and TypeScript for relative module imports
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
// src/store/reducers/workspace/canvas.ts | |
import { handleActions } from 'utils/store'; | |
/// ... |
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
// src/utils/store.ts | |
// .. | |
export function handleActions(map, defaultState) { | |
// .. | |
} | |
// ... |
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
{ | |
"compilerOptions": { | |
// ... your standard TS config here | |
"paths": { | |
"*": [ | |
"*", | |
"src/*" | |
] | |
} | |
} | |
} |
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
const config = { | |
// your standard Webpack config here | |
// ... | |
resolve: { | |
// ... | |
modules: [ | |
// Here is the important part | |
path.join(__dirname, 'src'), | |
'node_modules', | |
], | |
}, | |
}; | |
module.exports = config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works like charm, thank you for sharing this! For me, it even worked with less configuration: I hadn't had to specify path mapping
"*": [ "*", "src/*" ]
in mytsconfig.json
, onlybaseUrl: './src'
.