I am currently in the process of transforming a relatively intricate shiny application (consisting of 3-4 modules and 8 CSS/JS files) into a package with a single external function that constructs an instance of the app based on specific input (
build_myApp(dataset1, title, factors)
). This function is stored in build_myApp.R
within the R/
directory, alongside myApp_server.R
, myApp_ui.R
, and various helper files.
Following this example here has been successful so far, although I have encountered an issue where the styling of the app disappeared. In this post here, someone faced similar problems but did not attempt to "functionize" their app.
In the past, I would place external files in a top-level www
folder and call them from the top-level ui.R
file using codes like
tags$link(rel = "stylesheet", type = "text/css", href = "sample1.css")
or tags$script(src="www/sample.js")
. However, I am now unable to access any of these files, including other external CSS files, although it's hard to confirm for sure.
I have attempted different methods by leaving the www
header at the top level, placing it within an inst/
top-level folder, moving it within R/
, and restarting the R session each time I made changes. I have tried variations such as:
sample1.css
./sample2.css
../sample3.css
www/sample4.css
./www/sample5.css
../www/sample6.css
/www/sample7.css
inst/www/sample8.css
/inst/www/sample9.css
./inst/www/sample10.css
../inst/www/sample11.css
inst/sample12.css
/inst/sample13.css
./inst/sample14.css
../inst/sample15.css
Regrettably, the Mastering Shiny Chapter does not address this issue, and I haven't found any relevant information online. Any guidance on this matter would be greatly appreciated. Thank you!