Why does create-react-app creates both App.js and index.js?

后端 未结 2 1594
一向
一向 2021-02-02 08:26

I started learning React and now I\'m trying to understand what is the purpose of the index.js and App.js which are created by by running create-react-

2条回答
  •  攒了一身酷
    2021-02-02 09:02

    create-react-app use a plugin for webpack that name is html-webpack-plugin and this plugin use index.js for entrypoint like below :

    const HtmlWebpackPlugin = require('html-webpack-plugin')
    
    module.exports = {
     entry: 'index.js',
     output: {
    path: __dirname + '/dist',
    filename: 'index_bundle.js'
    },
     plugins: [
    new HtmlWebpackPlugin()
     ]
    }
    

    this plugin use for generating html file.

提交回复
热议问题