diff --git a/DESCRIPTION b/DESCRIPTION index 18a8a1592..136af9997 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -22,7 +22,7 @@ Imports: grDevices, htmltools (>= 0.4.0.9003), jsonlite, - sass (>= 0.2.0.9001), + sass (>= 0.2.0.9002), jquerylib (>= 0.1.2), rlang Suggests: diff --git a/R/bs_sass.R b/R/bs_sass.R index 1b9087df0..189f13dae 100644 --- a/R/bs_sass.R +++ b/R/bs_sass.R @@ -58,55 +58,23 @@ bootstrap <- function(theme = bs_theme_get(), theme <- as_bs_theme(theme) version <- theme_version(theme) minified <- isTRUE(sass_options$output_style %in% c("compressed", "compact")) - output_css <- if (minified) "bootstrap-custom.min.css" else "bootstrap-custom.css" - js <- bootstrap_javascript(version, minified) - - cache_key <- sass::sass_hash(list( - theme, - sass_options, - get_exact_version(version), - utils::packageVersion("bootstraplib") - )) - - # Temp dir for building the HTML dependencies - output_path <- file.path( - tempdir(), - "bootstraplib", - paste0("bootstrap-", cache_key) - ) - - # If the output path already exists, then we don't need to write anything. - if (!dir.exists(output_path)) { - dir.create(output_path, recursive = TRUE) - - # Compile sass in temp dir - sass::sass( + c( + if (inherits(jquery, "html_dependency")) list(jquery) else jquery, + sass::sass_html_dependencies( input = theme, + name = "bootstrap", + version = get_exact_version(version), + stylesheet = if (minified) "bootstrap-custom.min.css" else "bootstrap-custom.css", + cache_key = list(get_exact_version(version), utils::packageVersion("bootstraplib")), options = sass_options, - output = file.path(output_path, output_css), + write_attachments = TRUE, cache = cache, - write_attachments = TRUE - ) - - file.copy(js, output_path) - } - - c( - if (inherits(jquery, "html_dependency")) list(jquery) else jquery, - list( - htmlDependency( - "bootstrap", - if (version %in% "3") version_bs3 else version_bs4, - src = output_path, - meta = c( - name = "viewport", - content = "width=device-width, initial-scale=1, shrink-to-fit=no" - ), - stylesheet = output_css, - script = basename(js) + script = bootstrap_javascript(version, TRUE), + meta = c( + name = "viewport", + content = "width=device-width, initial-scale=1, shrink-to-fit=no" ) - ), - theme$html_deps + ) ) } @@ -120,5 +88,3 @@ bootstrap_sass <- function(rules = list(), theme = bs_theme_get(), ...) { theme$rules <- "" sass::sass(input = list(theme, rules), ...) } - -