gpt4 book ai didi

android - 在 Cordova 中使用 Webpack 时出现“找不到文件”错误

转载 作者:搜寻专家 更新时间:2023-11-01 08:23:21 25 4
gpt4 key购买 nike

我正在尝试使用 Webpack 和 Cordova 构建应用程序。我将我的 webpack 'dist' 文件夹的内容放入我的 cordova 'www' 文件夹,然后我为 Android 构建它并模拟它。

当应用程序打开时,我收到很多“ERR_FILE_NOT_FOUND”错误,当我打开已编译的 index.html 时,我看到每个链接前面都有一个“/”导致错误,因为它指向错误的目录.

Example'src=/static/js/example.js'

如果我手动删除第一个“/”并重新构建适用于 Android 的应用程序,它就可以正常工作。

如何在编译项目时删除那些“/”,这样我就不必在编译后手动编辑每个链接?

Example:

It should look for the files in the same folder as the index.html: "file:///android_asset/www/index.html#/"

instead it goes to:'file:///static/js/example.js'

(静态图与index.html同级)

注意:当我直接在浏览器中打开 index.html 时,链接有效

最佳答案

在 webpack 配置中添加 publicPath: '' 似乎已经解决了这个问题!

关于android - 在 Cordova 中使用 Webpack 时出现“找不到文件”错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47875788/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com