Publishing Shiny App Package with www/ Folder

Hello, I'm a new member to this community and relatively new to Shiny and building packages. Following Hadley Wickham's advice in Chapter 20 of Mastering Shiny (Chapter 20 Packages | Mastering Shiny), I have converted an existing app to a package, but I ran into the same problem with the resources in the www/ folder not loading noted in this topic:
Shiny app as a package - directory structure and www folder - shiny - RStudio Community

I ended up following the advice of @cnbrownlie which worked great running the app locally.

Now I am struggling to publish the app in this new layout to Posit Connect using rsconnect::deployApp() it returns an error due to invalid project layout.

Error in lint(appDir, appFiles, appPrimaryDoc) : 
  Cancelling deployment: invalid project layout.
The project should have one of the following layouts:
1. 'server.R' and 'ui.R' in the application base directory,
2. 'server.R' and 'www/index.html' in the application base directory,
3. 'app.R' or a single-file Shiny .R file,
4. An R Markdown (.Rmd) or Quarto (.qmd) document,
5. A static HTML (.html) or PDF (.pdf) document.
6. 'plumber.R' API description .R file
7. 'entrypoint.R' plumber startup script
8. A tensorflow saved model

The file structure is as follows:

├── R/
       ├── run_app.R
├── inst/
       ├── app/
            ├── app.R
            ├── www/
├── DESCRIPTION

Is there a way to deploy an app-package laid out this way? Or do I need to change my layout and handle the www/ folder issue differently?

I think I figured out the issue. It seems like the instructions in Mastering Shiny 20.3.1 are ambiguous and misleading where it says:

You’ll need an app.R that tells the deployment server how to run your app. The easiest way is to load the code with pkgload:

pkgload::load_all(".")
myApp()

This is confusing because if you follow the instructions, you already have an app.R in the R/ directory, but it looks like you need to make another one in the project's root directory. Someone else has also noticed this issue on the book's Github repo.

I tested the idea using the example month app from the chapter. The app now deploys.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.