taro h5执行打包操作报错

rkkpypqq  于 3个月前  发布在  其他
关注(0)|答案(5)|浏览(46)

相关平台

H5

复现仓库

https://gitee.com/yamlling_admin/taro-react-taroui.git
浏览器版本: edge127.0.2651.98
使用框架: React

复现步骤

npm run build:h5

期望结果

打包成功

实际结果

vite v4.5.3 building for production...
✓ 3 modules transformed.
✓ built in 72ms
[vite]: Rollup failed to resolve import "\app.config.ts" from "C:/Users/Notx200/Desktop/react-app/src/index.html".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
build.rollupOptions.external
file:///C:/Users/Notx200/Desktop/react-app/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:48216
throw new Error( [vite]: Rollup failed to resolve import "${exporter}" from "${id}".\n
^

Error: [vite]: Rollup failed to resolve import "\app.config.ts" from "C:/Users/Notx200/Desktop/react-app/src/index.html".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
build.rollupOptions.external
at viteWarn (file:///C:/Users/Notx200/Desktop/react-app/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:48216:27)
at onwarn (C:\Users\Notx200\Desktop\react-app\node_modules@vitejs\plugin-react\dist\index.cjs:274:9)
at onRollupWarning (file:///C:/Users/Notx200/Desktop/react-app/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:48245:9)
at onwarn (file:///C:/Users/Notx200/Desktop/react-app/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:47976:13)
at file:///C:/Users/Notx200/Desktop/react-app/node_modules/rollup/dist/es/shared/node-entry.js:24276:13
at Object.logger [as onLog] (file:///C:/Users/Notx200/Desktop/react-app/node_modules/rollup/dist/es/shared/node-entry.js:25950:9)
at ModuleLoader.handleInvalidResolvedId (file:///C:/Users/Notx200/Desktop/react-app/node_modules/rollup/dist/es/shared/node-entry.js:24862:26)
at file:///C:/Users/Notx200/Desktop/react-app/node_modules/rollup/dist/es/shared/node-entry.js:24822:26 {
watchFiles: [
'taro:compiler',
'C:\Users\Notx200\Desktop\react-app\src\pages\index\index.config.ts',
'C:\Users\Notx200\Desktop\react-app\src\pages\car\index.config.ts',
'C:/Users/Notx200/Desktop/react-app/src/index.html',
'\x00vite/modulepreload-polyfill'
]
}

Node.js v18.20.4

环境信息

Taro v4.0.4

  Taro CLI 4.0.4 environment info:
    System:
      OS: Windows 11 10.0.22621
    Binaries:
      Node: 18.20.4 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.22 - C:\Program Files\nodejs\yarn.CMD
      npm: 10.7.0 - C:\Program Files\nodejs\npm.CMD
    npmPackages:
      @tarojs/cli: 4.0.4 => 4.0.4
      @tarojs/components: 4.0.4 => 4.0.4
      @tarojs/helper: 4.0.4 => 4.0.4
      @tarojs/plugin-framework-react: 4.0.4 => 4.0.4
      @tarojs/plugin-platform-alipay: 4.0.4 => 4.0.4
      @tarojs/plugin-platform-h5: 4.0.4 => 4.0.4
      @tarojs/plugin-platform-harmony-hybrid: 4.0.4 => 4.0.4
      @tarojs/plugin-platform-jd: 4.0.4 => 4.0.4
      @tarojs/plugin-platform-qq: 4.0.4 => 4.0.4
      @tarojs/plugin-platform-swan: 4.0.4 => 4.0.4
      @tarojs/plugin-platform-tt: 4.0.4 => 4.0.4
      @tarojs/plugin-platform-weapp: 4.0.4 => 4.0.4
      @tarojs/react: 4.0.4 => 4.0.4
      @tarojs/runtime: 4.0.4 => 4.0.4
      @tarojs/shared: 4.0.4 => 4.0.4
      @tarojs/taro: 4.0.4 => 4.0.4
      @tarojs/vite-runner: 4.0.4 => 4.0.4
      babel-preset-taro: 4.0.4 => 4.0.4
      eslint-config-taro: 4.0.4 => 4.0.4
      react: ^18.0.0 => 18.3.1
      taro-ui: ^3.3.0 => 3.3.0
hs1ihplo

hs1ihplo2#

在linux下试了下 可以成功打包, 初步判断应该是windows路径的问题

dxxyhpgq

dxxyhpgq3#

迁移到webpack正常,vite不行

pxq42qpu

pxq42qpu4#

迁移到webpack正常,vite不行

目前只能使用linux打包

ca1c2owp

ca1c2owp5#

迁移到webpack正常,vite不行

请问如何迁移到webpack

相关问题