起因:build上传gitee,启用路由需要404.html自动跳转
当前环境 create-react-app 搭建的架子
解决方案
由于默认的时候把build.js打包,无法查看,只好eject
有不需要eject的方法,但是为了更好的研究学习,就得eject
- npm run eject
- 找到 script/build.js
- 找到编译index.html的命令,然后在生成index.html之后进行404.html文件的copy
- 添加copy命令
fs.copyFileSync('build/index.html', 'build/404.html');
思路分析
- 先找 build.js
- 找copy函数 copyPublicFolder
- 找生成index.html函数 return build(previousFileSizes);
- 找生成index.html后的then()
- 找到插入位置前 console.log(chalk.green('Compiled successfully.\n'));
---------------------------------------------
生活的意义并不是与他人争高下,而在于享受努力实现目标的过程,结果是对自己行动的嘉奖。
↑面的话,越看越不痛快,应该这么说:
生活的意义就是你自己知道你要做什么,明确目标。没有目标,后面都是瞎扯!
新博客 https://www.VuejsDev.com 用于梳理知识点