webpacks react code example

Example 1: add webpack to react project

{  "presets": [    "@babel/preset-env",    "@babel/preset-react"  ]}

Example 2: add webpack to react project

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'  }};