react 打包遇到的问题

1. npm run build 打包后报错

Child html-webpack-plugin for "..\index.html":1 asset
Entrypoint html-webpack-plugin for "..\index.html" = ../index.html
Child mini-css-extract-plugin node_modules/css-loader/index.js!node_modules/ivie
w/dist/styles/iview.css:
Entrypoint mini-css-extract-plugin = *

或者 报错  

Entrypoint undefined = index.html

解决办法:

在webpack.config.js文件加上

stats: {
// One of the two if I remember right
entrypoints: false,
children: false
},

2. yarn start时许可证警告且下边有端口,可以看是否端口被占用

3. 不识别  NODE_ENV=\"production\"

安装   npm install --save-dev cross-env (cross-env能跨平台地设置及使用环境变量)

在npm脚本(package.json)里这么使用:

"start": "cross-env NODE_ENV=development webpack-dev-server --colors --config ./build_scripts/webpack.config.js",
4. 有些错有可能是webpack 和 bable 版本不兼容的问题
5. 报错这个   在build生成的dist目录下index.html中 更改静态资源引用路径

6. serve -s build  会将打包后的东西在本地测试

7. 若要在外部运行打包的东西需要服务器,放在tomcat 下 webapps 的ROOT目录下 然后运行端口。

 

 

posted @ 2019-06-17 15:14  lal_z  阅读(570)  评论(0编辑  收藏  举报