I did this in next config:
const config = {
webpack(config) {
config.resolve.alias[package.name] = path.resolve(__dirname, 'src');
return config;
}
};
So then I can import by app name import Input from 'my-app/components/input'
You also need to add it to tsconfig.json. You are using typescript with next.js. I got it working like this
My tsconfig.json
"baseUrl": ".",
"paths": {
"@": ["src/"],
"@/*": ["src/*"],
}
My next.config.js webpack
config.resolve.alias['@'] = path.join(__dirname, 'src')
Removing one or the other breaks it.
@JazibJafri, it works, thanks a lots.
https://github.com/zeit/next.js/pull/11293
This will solve your issue better :)
@Exelord You just saved me a whole lot of strife. Thannnnnk ya!
Most helpful comment
@Exelord You just saved me a whole lot of strife. Thannnnnk ya!