Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide default index.html when webDir is not found #3990

Closed
imhoffd opened this issue Dec 23, 2020 · 3 comments
Closed

Provide default index.html when webDir is not found #3990

imhoffd opened this issue Dec 23, 2020 · 3 comments
Labels
cli dx improves developer experience enhancement
Milestone

Comments

@imhoffd
Copy link
Contributor

imhoffd commented Dec 23, 2020

Most apps using Capacitor are using webpack (via Angular CLI, react-scripts, etc) or similar build system, which means the webDir directory is a generated asset, not typically committed to source control. Fresh checkouts that run sync end up with this error:

❯ npx cap sync
[error] Could not find the web assets directory: /Users/dan/git/capacitor-testapp/build.
        Please create it and make sure it has an index.html file. You can change the path of this directory in
        capacitor.config.ts (webDir option). You may need to compile the web assets for your app (typically npm run
        build).
        More info: https://capacitorjs.com/docs/v3/basics/workflow#sync-your-project

Additionally, the Angular CLI (and possibly others) remove the webDir folder by default when using ng serve. This is possible because webpack-dev-server serves assets from memory, not the filesystem.

We can improve the developer experience by providing a default index.html for Capacitor to use during sync, which would get copied into the native platform resources and shown in the device with instructions for building their app and re-running sync. When using livereload, the default index.html wouldn't be seen--it would load their app from the dev server.

@imhoffd imhoffd added enhancement dx improves developer experience labels Dec 23, 2020
@imhoffd imhoffd added this to the 3.0.0-rc milestone Dec 23, 2020
@imhoffd imhoffd added the cli label Dec 23, 2020
@jcesarmobile
Copy link
Member

I, as user, would find more annoying that sync works but when I run I get a default index.html rather than my app.

Since your use case is live reload, maybe would be better to not try to copy files if the server url is set?

@imhoffd
Copy link
Contributor Author

imhoffd commented Jan 7, 2021

Yeah, I think that will work. 👉 #4028

@imhoffd imhoffd closed this as completed Jan 7, 2021
@ionitron-bot
Copy link

ionitron-bot bot commented Nov 11, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cli dx improves developer experience enhancement
Projects
None yet
Development

No branches or pull requests

2 participants