TLDR
Is is possible to use relative imports (like import foo from 'path/to/foo';
) inside webpack.config.ts
and other inner modules which are also imported in webpack.config.ts
?
Long description
It is commonly known how to configure Webpack and Typescript in a way that they begin to understand how to read so called module imports:
import app from 'app';
However, my webpack.config.ts
itself contains imports from modules located inside src
folder. Those modules, in turn, have other imports from another modules and so on. For instance:
// webpack.config.ts:
import wifiConnector from './src/libs/wifiConnector'; // Let it be absolute here.
export default (env: Environment) => {
// Config uses wifiConnector.
}
// src/libs/wifiConnector:
import foo from 'utils/foo';
const wifiConnector = () => {
// ...
}
export default wifiConnector;
When you try to run this kind of webpack configuration you get an error:
Failed to load 'webpack.config.ts' config
So it forces me to use absolute imports inside src/libs/wifiConnector
too:
// src/libs/wifiConnector:
import foo from '../utils/foo'; // This works perfectly fine.
...
However, I want all imports inside src
folder to be relative. Is it possible to accomplish?
I tried to google a solution, or at least the similar question asked but didn't have any luck.