m***@163.com
m***@163.com
  • 发布:2022-08-04 10:24
  • 更新:2022-08-18 09:34
  • 阅读:824

【报Bug】HBuilderX 3.5.3 版本打包 APP 报错

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: Windows 10 专业版

HBuilderX版本号: 3.5.3

手机系统: Android

手机系统版本号: Android 9.0

手机厂商: ONEPLUS

手机机型: A6010

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: CLI

CLI版本号: 2.0.1-34920220630001

操作步骤:

以下是package.json 的配置
···
{
"name": "digital_app",
"version": "1.0.0",
"private": true,
"scripts": {
"serve": "npm run dev:h5",
"build": "npm run build:h5",
"build:app-plus": "cross-env NODE_ENV=production UNI_PLATFORM=app-plus vue-cli-service uni-build",
"build:custom": "cross-env NODE_ENV=production uniapp-cli custom",
"build:h5": "cross-env NODE_ENV=production UNI_PLATFORM=h5 vue-cli-service uni-build",
"build:mp-360": "cross-env NODE_ENV=production UNI_PLATFORM=mp-360 vue-cli-service uni-build",
"build:mp-alipay": "cross-env NODE_ENV=production UNI_PLATFORM=mp-alipay vue-cli-service uni-build",
"build:mp-baidu": "cross-env NODE_ENV=production UNI_PLATFORM=mp-baidu vue-cli-service uni-build",
"build:mp-jd": "cross-env NODE_ENV=production UNI_PLATFORM=mp-jd vue-cli-service uni-build",
"build:mp-kuaishou": "cross-env NODE_ENV=production UNI_PLATFORM=mp-kuaishou vue-cli-service uni-build",
"build:mp-lark": "cross-env NODE_ENV=production UNI_PLATFORM=mp-lark vue-cli-service uni-build",
"build:mp-qq": "cross-env NODE_ENV=production UNI_PLATFORM=mp-qq vue-cli-service uni-build",
"build:mp-toutiao": "cross-env NODE_ENV=production UNI_PLATFORM=mp-toutiao vue-cli-service uni-build",
"build:mp-weixin": "cross-env NODE_ENV=production UNI_PLATFORM=mp-weixin vue-cli-service uni-build",
"build:mp-xhs": "cross-env NODE_ENV=production UNI_PLATFORM=mp-xhs vue-cli-service uni-build",
"build:quickapp-native": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-native vue-cli-service uni-build",
"build:quickapp-webview": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview vue-cli-service uni-build",
"build:quickapp-webview-huawei": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview-huawei vue-cli-service uni-build",
"build:quickapp-webview-union": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview-union vue-cli-service uni-build",
"dev:app-plus": "cross-env NODE_ENV=development UNI_PLATFORM=app-plus vue-cli-service uni-build --watch",
"dev:custom": "cross-env NODE_ENV=development uniapp-cli custom",
"dev:h5": "cross-env NODE_ENV=development UNI_PLATFORM=h5 vue-cli-service uni-serve",
"dev:mp-360": "cross-env NODE_ENV=development UNI_PLATFORM=mp-360 vue-cli-service uni-build --watch",
"dev:mp-alipay": "cross-env NODE_ENV=development UNI_PLATFORM=mp-alipay vue-cli-service uni-build --watch",
"dev:mp-baidu": "cross-env NODE_ENV=development UNI_PLATFORM=mp-baidu vue-cli-service uni-build --watch",
"dev:mp-jd": "cross-env NODE_ENV=development UNI_PLATFORM=mp-jd vue-cli-service uni-build --watch",
"dev:mp-kuaishou": "cross-env NODE_ENV=development UNI_PLATFORM=mp-kuaishou vue-cli-service uni-build --watch",
"dev:mp-lark": "cross-env NODE_ENV=development UNI_PLATFORM=mp-lark vue-cli-service uni-build --watch",
"dev:mp-qq": "cross-env NODE_ENV=development UNI_PLATFORM=mp-qq vue-cli-service uni-build --watch",
"dev:mp-toutiao": "cross-env NODE_ENV=development UNI_PLATFORM=mp-toutiao vue-cli-service uni-build --watch",
"dev:mp-weixin": "cross-env NODE_ENV=development UNI_PLATFORM=mp-weixin vue-cli-service uni-build --watch",
"dev:mp-xhs": "cross-env NODE_ENV=development UNI_PLATFORM=mp-xhs vue-cli-service uni-build --watch",
"dev:quickapp-native": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-native vue-cli-service uni-build --watch",
"dev:quickapp-webview": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview vue-cli-service uni-build --watch",
"dev:quickapp-webview-huawei": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview-huawei vue-cli-service uni-build --watch",
"dev:quickapp-webview-union": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview-union vue-cli-service uni-build --watch",
"info": "node node_modules/@dcloudio/vue-cli-plugin-uni/commands/info.js",
"serve:quickapp-native": "node node_modules/@dcloudio/uni-quickapp-native/bin/serve.js",
"test:android": "cross-env UNI_PLATFORM=app-plus UNI_OS_NAME=android jest -i",
"test:h5": "cross-env UNI_PLATFORM=h5 jest -i",
"test:ios": "cross-env UNI_PLATFORM=app-plus UNI_OS_NAME=ios jest -i",
"test:mp-baidu": "cross-env UNI_PLATFORM=mp-baidu jest -i",
"test:mp-weixin": "cross-env UNI_PLATFORM=mp-weixin jest -i"
},
"dependencies": {
"@dcloudio/uni-app-plus": "^2.0.1-34920220630001",
"@dcloudio/uni-h5": "^2.0.1-34920220630001",
"@dcloudio/uni-helper-json": "",
"@dcloudio/uni-i18n": "^2.0.1-34920220630001",
"@dcloudio/uni-mp-360": "^2.0.1-34920220630001",
"@dcloudio/uni-mp-alipay": "^2.0.1-34920220630001",
"@dcloudio/uni-mp-baidu": "^2.0.1-34920220630001",
"@dcloudio/uni-mp-jd": "^2.0.1-34920220630001",
"@dcloudio/uni-mp-kuaishou": "^2.0.1-34920220630001",
"@dcloudio/uni-mp-lark": "^2.0.1-34920220630001",
"@dcloudio/uni-mp-qq": "^2.0.1-34920220630001",
"@dcloudio/uni-mp-toutiao": "^2.0.1-34920220630001",
"@dcloudio/uni-mp-vue": "^2.0.1-34920220630001",
"@dcloudio/uni-mp-weixin": "^2.0.1-34920220630001",
"@dcloudio/uni-mp-xhs": "^2.0.1-34920220630001",
"@dcloudio/uni-quickapp-native": "^2.0.1-34920220630001",
"@dcloudio/uni-quickapp-webview": "^2.0.1-34920220630001",
"@dcloudio/uni-stat": "^2.0.1-34920220630001",
"@dcloudio/vue-cli-plugin-uni": "^2.0.1-34920220630001",
"@dcloudio/vue-cli-plugin-uni-optimize": "^2.0.1-34920220630001",
"@vue/cli-service": "~4.5.19",
"@vue/shared": "^3.0.0",
"cross-env": "^7.0.2",
"core-js": "^3.6.5",
"flyio": "^0.6.2",
"html2canvas": "^1.4.1",
"regenerator-runtime": "^0.12.1",
"vue": "^2.6.11",
"vue-clipboard2": "^0.3.3",
"vue-puzzle-vcode": "^1.1.9",
"vue-qr": "^4.0.9",
"vuex": "^3.2.0"
},
"devDependencies": {
"@babel/runtime": "~7.17.9",
"@dcloudio/types": "^3.0.4",
"@dcloudio/uni-automator": "^2.0.1-34920220630001",
"@dcloudio/uni-cli-i18n": "^2.0.1-34920220630001",
"@dcloudio/uni-cli-shared": "^2.0.1-34920220630001",
"@dcloudio/uni-migration": "^2.0.1-34920220630001",
"@dcloudio/uni-template-compiler": "^2.0.1-34920220630001",
"@dcloudio/vue-cli-plugin-hbuilderx": "^2.0.1-34920220630001",
"@dcloudio/vue-cli-plugin-uni": "^2.0.1-34920220630001",
"@dcloudio/vue-cli-plugin-uni-optimize": "^2.0.1-34920220630001",
"@dcloudio/webpack-uni-mp-loader": "^2.0.1-34920220630001",
"@dcloudio/webpack-uni-pages-loader": "^2.0.1-34920220630001",
"@vue/cli-plugin-babel": "~4.5.19",
"@vue/cli-service": "~4.5.19",
"babel-plugin-import": "^1.11.0",
"cross-env": "^7.0.2",
"jest": "^25.4.0",
"mini-types": "
",
"miniprogram-api-typings": "*",
"postcss-comment": "^2.0.0",
"sass": "^1.49.8",
"sass-loader": "^8.0.2",
"three": "^0.142.0",
"vue-template-compiler": "^2.6.11"
},
"browserslist": [
"Android >= 4.4",
"ios >= 9"
],
"resolutions": {
"@babel/runtime": "~7.17.9"
},
"uni-app": {
"scripts": {}
}
}

···

预期结果:

打包成功

实际结果:

打包失败

bug描述:

打包模式及bug 报错如下所示:

2022-08-04 10:24 负责人:无 分享
已邀请:
m***@163.com

m***@163.com (作者)

插件 @dcloudio/vue-cli-plugin-uni 里
vue-cli-plugin-uni/lib/chain-webpack.js 路径下
这段代码中 options 未加非 undefined 判断

if (sassLoaderVersion >= 8) { // check indentedSyntax  
      // vue cli 3 and sass-loader 8  
      cssTypes.forEach(type => {  
        webpackConfig.module.rule('sass').oneOf(type).use('sass-loader').tap(options => {  
          if (options.indentedSyntax) {  
            if (!options.sassOptions) {  
              options.sassOptions = {}  
            }  
            options.sassOptions.indentedSyntax = true  
            delete options.indentedSyntax  
          }  
          return options  
        })  
      })  
    }

修改后代码

if (sassLoaderVersion >= 8) { // check indentedSyntax  
      // vue cli 3 and sass-loader 8  
      cssTypes.forEach(type => {  
        webpackConfig.module.rule('sass').oneOf(type).use('sass-loader').tap(options => {  
          if (options && options.indentedSyntax) {  
            if (!options.sassOptions) {  
              options.sassOptions = {}  
            }  
            options.sassOptions.indentedSyntax = true  
            delete options.indentedSyntax  
          }  
          return options  
        })  
      })  
    }

修改后能顺利打包

m***@163.com

m***@163.com (作者)

在 CLI 版本 2.0.1-35320220729002 中官方已经修复了该bug,如果遇到该问题,建议升级 CLI 到最新版本

该问题目前已经被锁定, 无法添加新回复