本次施工react版本为"react": "^16.13.1",
yarn eject后
先在public文件中增加所需html文件:

进入config/paths.js查找appHtml及appIndexJs字段添加以下内容:

src文件结构如下:

进入config/webpack.config.js施工部分如下:

4

5

6

7

8
运行
yarn build


如果出现了Cannot read property 'filter' of undefined报错

解决办法如下:
在config/webpack.config.js文件下找到ManifestPlugin函数,注释掉generate参数或者取消entrypoints这个值的传递
ManifestPlugin这个插件的作用是生成一份.json的文件,通过该文件的映射关系可以让我们知道webpack是如何追踪所有模块并映射到输出bundle中的
//config/webpack.config.js
new ManifestPlugin({
fileName: 'asset-manifest.json',
publicPath: paths.publicUrlOrPath,
// generate: (seed, files, entrypoints) => {
// const manifestFiles = files.reduce((manifest, file) => {
// manifest[file.name] = file.path;
// return manifest;
// }, seed);
// const entrypointFiles = entrypoints.main.filter(
// fileName => !fileName.endsWith('.map')
// );
// return {
// files: manifestFiles,
// entrypoints: entrypointFiles,
// };
// },
}),