Reputation: 141
I have a Vue.js project A which I want to reuse in another Vue.js project B.
They have pretty similar setup: Vue.js + Typescript
I try to import components from A to B. What I do:
This component uses some utils from the A project in this way:
import { func } from '@/utils/functions';
A project has specified paths option in tsconfig.json:
"paths": {
"@/*": [
"src/*"
]
}
When I start the B app I get an error that says:
This dependency was not found:
* @/utils/functions
It seems like relative paths specified in this way (@/
) is not resolved in node_modules.
So, how should I define the tsconfig.json in B project to resolve this dependency for my imported component? Or is there any other way to do what I described above (maybe something about webpack configs)?
Upvotes: 0
Views: 514
Reputation: 1260
in webpack config try something like that
module.exports = {
configureWebpack: {
resolve: {
alias: {
'@': path.join(__dirname, 'src'),
}
},
}
}
Upvotes: 2