USGS-VIZLAB / vizlab

Package with utilities for building vizlab pages
Creative Commons Zero v1.0 Universal
25 stars 14 forks source link

Run css preprocessor as part of build #12

Open jiwalker-usgs opened 8 years ago

jiwalker-usgs commented 8 years ago

We will want to move styling to less/sass/scss, so we should compile this as part of the build.

aappling-usgs commented 6 years ago

Using Less could really clean up the CSS process - see http://winless.org/online-less-compiler to understand how powerful Less is. It reduces redundancy by allowing for variables and mixins, offers basic arithmetic and color-modifying functions, can organize code into namespaces, provides string templating, and more.

Despite the benefits, this issue has been stagnant a long time because:

  1. We'd want to carefully manage how people edit the files - they'd need to switch from editing CSS to editing the Less files, and if someone edited the CSS it would be overwritten by the next Less compilation, which would be frustrating. And vizlab sprints are a bad time to overwrite work or get frustrated. So we'd like to prevent people from editing the CSS files, and provide them with an easy way to compile the Less files so they can see their changes locally and immediately.
  2. One solution to the people problem would be to configure vizlab/RStudio so that CSS automatically compiles when you save the Less file. BUT it was difficult to find a compiler that would link to RStudio in that way and would work for everyone (mac/windows/linux), so progress on this issue stalled.

@mwernimont cautions that we should "know what minefield we are walking into" before really gunning for this. But he would like to be able to use Less, on a "would be nice" level or maybe a little higher.

I'd like to see another attempt at this. I think we could manage the CSS vs Less problem through PR reviews and good communication - plus, I think many vizmeisters would quickly learn to appreciate & embrace the Less approach. And even if we can't do instantaneous compilation on save, surely we could find a way to compile Less files from R on 3 platforms, with an if() switch to figure out which platform each developer is on. That compilation command could be run by the developer directly and repeatedly while they're editing, and could be part of the standard viz build process to ensure the CSS files are up to date when PRs are submitted. If we're willing to sacrifice some of the complete solution that was originally envisioned, I think this can be done.