I am having a hard time setting up my webpack-babel config for my react-typescript project.
When I try to build with the command rm -rf ./dist && webpack --mode production it throws an error like this:
[webpack-cli] TypeError: compiler.getInfrastructureLogger is not a function
at CLIPlugin.apply (/Users/VIU/Projects/prueba-axpe-consulting-2/my-app/node_modules/webpack-cli/lib/plugins/CLIPlugin.js:116:32)
at WebpackCLI.webpack (/Users/VIU/Projects/prueba-axpe-consulting-2/my-app/node_modules/webpack/lib/webpack.js:37:12)
at WebpackCLI.createCompiler (/Users/VIU/Projects/prueba-axpe-consulting-2/my-app/node_modules/webpack-cli/lib/webpack-cli.js:2053:29)
at async WebpackCLI.buildCommand (/Users/VIU/Projects/prueba-axpe-consulting-2/my-app/node_modules/webpack-cli/lib/webpack-cli.js:2173:20)
at async Command.<anonymous> (/Users/VIU/Projects/prueba-axpe-consulting-2/my-app/node_modules/webpack-cli/lib/webpack-cli.js:850:25)
at async Promise.all (index 1)
at async Command.<anonymous> (/Users/VIU/Projects/prueba-axpe-consulting-2/my-app/node_modules/webpack-cli/lib/webpack-cli.js:1495:13)
my webpack.config.js
const path = require('path');
module.exports = {
entry: './src/index.tsx',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
chunkFilename: '[id].js',
publicPath: ''
}
};
Versions:
"devDependencies": {
"@babel/core": "^7.14.5",
"@babel/preset-env": "^7.14.5",
"@babel/preset-react": "^7.14.5",
"@babel/preset-typescript": "^7.14.5",
"babel-loader": "8.0.4",
"source-map-loader": "^3.0.0",
"webpack": "4.19.1",
"webpack-cli": "^4.7.2"
}
I am using yarn. Could someone tell me what I am doing wrong?
I had the same problem with webpack-cli@^4.7.2. I didn't have time to research the exact cause or fix. Instead, I searched for "getInfrastructureLogger" in the code, and replaced it with this.
this.logger = console; // compiler.getInfrastructureLogger("webpack-cli");
Any object that defines a log function should work. I know it's a hack, but it got me unblocked until I can find a more comprehensive solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With