禁止报错

This commit is contained in:
hackrobot
2025-04-14 10:16:42 -05:00
parent 2a64f28846
commit 8a227785d1
5 changed files with 21 additions and 4 deletions

View File

@@ -8,3 +8,6 @@ module.exports = {
}] }]
] ]
} }

View File

@@ -27,7 +27,10 @@ const config = {
}, },
h5: { h5: {
// 默认会编译为 es5修改为 es2017 或更高
esnext: true,
webpackChain(chain) { webpackChain(chain) {
chain.output.filename("static/js/[name].[contenthash:8].js"); chain.output.filename("static/js/[name].[contenthash:8].js");
chain.output.chunkFilename("static/js/[name].[contenthash:8].js"); chain.output.chunkFilename("static/js/[name].[contenthash:8].js");
chain chain
@@ -54,6 +57,7 @@ const config = {
simplify: true, // 开启简化,提高性能 simplify: true, // 开启简化,提高性能
// 禁用对 async/await 的转换 // 禁用对 async/await 的转换
target: "browser", // 或设置为适合目标环境的 ECMAScript 版本 target: "browser", // 或设置为适合目标环境的 ECMAScript 版本
disableOptimizations: true, // 禁用某些优化来避免处理 async/await disableOptimizations: true, // 禁用某些优化来避免处理 async/await
}, },
["**/*.js", "!node_modules/**"], // 避免对 node_modules 进行混淆 ["**/*.js", "!node_modules/**"], // 避免对 node_modules 进行混淆
@@ -125,6 +129,10 @@ const config = {
}, },
// 允许特定域名访问 // 允许特定域名访问
allowedHosts: ["nomadyt.com", "localhost", ".nomadyt.com"], // 允许所有 *.nomadyt.com 子域访问 allowedHosts: ["nomadyt.com", "localhost", ".nomadyt.com"], // 允许所有 *.nomadyt.com 子域访问
// ⬇️ 关键配置:禁用 overlay 错误弹出
client: {
overlay: false,
},
}, },
htmlPluginOption: { htmlPluginOption: {
favicon: path.resolve(__dirname, "..", "src", "images", "youtube.ico"), // 同样处理 favicon 路径 favicon: path.resolve(__dirname, "..", "src", "images", "youtube.ico"), // 同样处理 favicon 路径
@@ -135,7 +143,8 @@ const config = {
}, },
}, },
target: ["web", "browserslist:> 0.25%, not dead"], // target: ["web", "browserslist:> 0.25%, not dead"],
target: ["web", "es2017"], // 关键点!
}, },
}; };

View File

@@ -57,6 +57,7 @@
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.8.0", "@babel/core": "^7.8.0",
"@babel/preset-env": "^7.26.9",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.5", "@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
"@tarojs/cli": "3.6.20", "@tarojs/cli": "3.6.20",
"@tarojs/taro-loader": "3.6.20", "@tarojs/taro-loader": "3.6.20",
@@ -73,6 +74,7 @@
"javascript-obfuscator": "^4.1.1", "javascript-obfuscator": "^4.1.1",
"postcss": "^8.4.18", "postcss": "^8.4.18",
"react-refresh": "^0.11.0", "react-refresh": "^0.11.0",
"regenerator-runtime": "^0.14.1",
"stylelint": "9.3.0", "stylelint": "9.3.0",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"typescript": "^4.1.0", "typescript": "^4.1.0",

View File

@@ -5,6 +5,9 @@ import './app.scss'
import 'animate.css'; import 'animate.css';
import 'taro-ui/dist/style/index.scss' // 全局引入一次即可 import 'taro-ui/dist/style/index.scss' // 全局引入一次即可
import 'core-js/stable';
import 'regenerator-runtime/runtime'; // 用于支持 async/await
/** /**
* 有数埋点SDK 默认配置 * 有数埋点SDK 默认配置
* 使用方法请参考文档 https://mp.zhls.qq.com/youshu-docs/develop/sdk/Taro.html * 使用方法请参考文档 https://mp.zhls.qq.com/youshu-docs/develop/sdk/Taro.html
@@ -68,7 +71,7 @@ class App extends Component {
// this.props.children 是将要会渲染的页面 // this.props.children 是将要会渲染的页面
render () { render () {
return this.props.children return this.props?.children
} }
} }

View File

@@ -912,7 +912,7 @@
"@babel/helper-create-regexp-features-plugin" "^7.25.9" "@babel/helper-create-regexp-features-plugin" "^7.25.9"
"@babel/helper-plugin-utils" "^7.25.9" "@babel/helper-plugin-utils" "^7.25.9"
"@babel/preset-env@^7.11.0", "@babel/preset-env@^7.14.5": "@babel/preset-env@^7.11.0", "@babel/preset-env@^7.14.5", "@babel/preset-env@^7.26.9":
version "7.26.9" version "7.26.9"
resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.26.9.tgz#2ec64e903d0efe743699f77a10bdf7955c2123c3" resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.26.9.tgz#2ec64e903d0efe743699f77a10bdf7955c2123c3"
integrity sha512-vX3qPGE8sEKEAZCWk05k3cpTAE3/nOYca++JA+Rd0z2NCNzabmYvEiSShKzm10zdquOIAVXsy2Ei/DTW34KlKQ== integrity sha512-vX3qPGE8sEKEAZCWk05k3cpTAE3/nOYca++JA+Rd0z2NCNzabmYvEiSShKzm10zdquOIAVXsy2Ei/DTW34KlKQ==
@@ -11021,7 +11021,7 @@ regenerator-runtime@0.11:
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9"
integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg== integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==
regenerator-runtime@^0.14.0: regenerator-runtime@^0.14.0, regenerator-runtime@^0.14.1:
version "0.14.1" version "0.14.1"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz#356ade10263f685dda125100cd862c1db895327f" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz#356ade10263f685dda125100cd862c1db895327f"
integrity sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw== integrity sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==