add webpack to react project

JavaScript
npm i webpack webpack-cli --save-dev"scripts": {
  "build": "webpack --mode production"
}module.exports = {
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        exclude: /node_modules/,
        use: {
          loader: "babel-loader"
        }
      }
    ]
  }
};module.exports = {  entry: './src/index.js',  module: {    rules: [      {        test: /\.(js|jsx)$/,        exclude: /node_modules/,        use: ['babel-loader']      }    ]  },  resolve: {    extensions: ['*', '.js', '.jsx']  },  output: {    path: __dirname + '/dist',    publicPath: '/',    filename: 'bundle.js'  },  devServer: {    contentBase: './dist'  }};{  "presets": [    "@babel/preset-env",    "@babel/preset-react"  ]}
Source

Also in JavaScript: