Error Opening HTML File with Bundled JS and CSS in Android
See original GitHub issueEDIT: This issue is a duplicate of the one already discussed here: https://github.com/react-native-community/react-native-webview/issues/428
Original Text: HTML file with CSS and JavaScript bundled using Parcel or WebPack does not display in WebView. The bundled file displays fine when opened directly in a desktop browser. Additionally, the WebView is able to successfully open a regular web page.
The HTML file is imported into the component containing the WebView using the following code
const index = require('./dist/index.html');
This can be reproduced by creating an Expo project with a WebView in it. Building an HTML file with CSS and JS bundled into it, and then importing that file for use into the WebView. The Github repo at https://github.com/reggie3/react-native-webview-bundle-demo has a project demonstrates this technique and also reproduces this issue.
The expected behavior is that the HTML file is rendered correctly. The bundling technique has worked successfully in the past. I have used it successfully in the react-native-webview-leaflet project.
I a
Environment:
- OS: Windows 10, Mac Mojave, Android, iOS
- OS version: Win: 17134.829, Mac: 10.14.5, Android: One Plus 5 with Android 9, iPhone Simulator
- react-native version: Using Expo so https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz which is based on RN 0.59
- react-native-webview version: 0.11.4
Edit: I updated the repo to follow the style of react-native-webview-leaflet more closely and now the webview shows the text of the bundled file.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top GitHub Comments
@reggie3 how did you fix it ? Everything was working fine for me, then I suddenly got this issue.
same problem,it loads source code, not rendering html.