大海无量1
大海无量1
  • 发布:2023-01-10 15:16
  • 更新:2024-05-16 16:00
  • 阅读:569

【报Bug】cli生成vite+vue3项目,使用uni-ui报错 Invalid pattern

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: windows10

第三方开发者工具版本号: 3.6.4.20220922

基础库版本号: 3.0.0-3061320221209001

项目创建方式: CLI

CLI版本号: vite ^3.2.4

示例代码:

依赖包如下:

    "@dcloudio/uni-app": "3.0.0-3061320221209001",  
    "@dcloudio/uni-app-plus": "3.0.0-3061320221209001",  
    "@dcloudio/uni-components": "3.0.0-3061320221209001",  
    "@dcloudio/uni-h5": "3.0.0-3061320221209001",  
    "@dcloudio/uni-mp-alipay": "3.0.0-3061320221209001",  
    "@dcloudio/uni-mp-baidu": "3.0.0-3061320221209001",  
    "@dcloudio/uni-mp-kuaishou": "3.0.0-3061320221209001",  
    "@dcloudio/uni-mp-lark": "3.0.0-3061320221209001",  
    "@dcloudio/uni-mp-qq": "3.0.0-3061320221209001",  
    "@dcloudio/uni-mp-toutiao": "3.0.0-3061320221209001",  
    "@dcloudio/uni-mp-weixin": "3.0.0-3061320221209001",  
    "@dcloudio/uni-quickapp-webview": "3.0.0-3061320221209001",  
    "@dcloudio/uni-ui": "^1.4.23",  
    "pinia": "^2.0.28",  
    "staging": "^0.1.3",  
    "vue": "^3.2.45",  
    "vue-i18n": "^9.1.9"  
  },  
  "devDependencies": {  
    "@dcloudio/types": "^3.0.17",  
    "@dcloudio/uni-automator": "3.0.0-3061320221209001",  
    "@dcloudio/uni-cli-shared": "3.0.0-3061320221209001",  
    "@dcloudio/uni-stacktracey": "3.0.0-3061320221209001",  
    "@dcloudio/vite-plugin-uni": "3.0.0-3061320221209001",  
    "sass": "^1.56.2",  
    "sass-loader": "^8.0.0",  
    "vconsole": "^3.15.0",  
    "vite": "^3.2.4"  
  }```  

vite.config.js配置如下
```import { defineConfig } from "vite";  
import uni from "@dcloudio/vite-plugin-uni";  
import env from "@wopan/constant/env.json";  
// https://vitejs.dev/config/  
const isDev = process.env.NODE_ENV === "development";  

const baseProxy = {  
  target: env[isDev ? "development" : "production"].baseApi,  
  secure: false,  
  changeOrigin: true,  
};  
export default defineConfig({  
  optimizeDeps: ['@dcloudio/uni-ui'],  
  envDir:'envs',  
  server: {  
    proxy: {  
      "/wohome/dispatcher": baseProxy,  
      "/api-user/dispatcher": baseProxy,  
    },  
  },  
  plugins: [uni()],  
});

pages.json配置如下 {


        "autoscan": true,  
        "custom": {  
            "^uni-(.*)": "@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue"  
        }  
    },  
  "pages": [{ "path": "pages/index/index" }, { "path": "pages/login/index" },{"path":"pages/uploaddemo/uploaddemo"},{"path":"pages/uploadpage/uploadpage"}],  
  "globalStyle": {  
    "navigationStyle": "custom"  
  }  
}  
{  
  "easycom": {  
        "autoscan": true,  
        "custom": {  
            "^uni-(.*)": "@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue"  
        }  
    },  
  "pages": [{ "path": "pages/index/index" }, { "path": "pages/login/index" },{"path":"pages/uploaddemo/uploaddemo"},{"path":"pages/uploadpage/uploadpage"}],  
  "globalStyle": {  
    "navigationStyle": "custom"  
  }  
}```

操作步骤:

npm run dev:mp-weixin --mode staging

预期结果:

编译成功,生成小程序包

实际结果:

Compiling...  
vite v3.2.4 building for development...  
Invalid pattern "../../node-modules/@dcloudio/uni-ui/lib/uni-popup/uni-popup.js" for "output.chunkFileNames", patterns can be neither absolute nor relative paths. If you want your files to be stored in a subdirectory, write its name without a leading slash like this: subdirectory/pattern.```

bug描述:

uni-app (vite+vue3,npm安装) 使用uni-ui popup组件
微信环境开发模式运行报错如下:


uni -p mp-weixin "staging"  
Please note that in running mode, due to log output, sourcemap, and uncompressed source code, the performance and package size are not as good as release mode.To officially release, please click the release menu or use the cli release command to release  
Compiling...  
vite v3.2.4 building for development...  
Invalid pattern "../../node-modules/@dcloudio/uni-ui/lib/uni-popup/uni-popup.js" for "output.chunkFileNames", patterns can be neither absolute nor relative paths. If you want your files to be stored in a subdirectory, write its name without a leading slash like this: subdirectory/pattern.```  
2023-01-10 15:16 负责人:无 分享
已邀请:
7***@qq.com

7***@qq.com

请问 解决了么

要回复问题请先登录注册