Skip to content

Instantly share code, notes, and snippets.

@mfdj
Last active January 31, 2016 20:59
Show Gist options
  • Save mfdj/bf547be954cdb768ed7c to your computer and use it in GitHub Desktop.
Save mfdj/bf547be954cdb768ed7c to your computer and use it in GitHub Desktop.
Decoupling from rails-sass and asset-pipeline and moving to sassc
# assuming you have a root stylesheet like app/assets/stylesheets/application.scss you can easily generate all your import
# statements with a single line of BASH
# look in all of the sub-folders of app/assets/stylesheets/ for scss files
# find app/assets/stylesheets/*/* -name '*.scss'
# ignore the first 24 characters of the path (i.e. `app/assets/stylesheets/`)
# cut -c 24-
# create import statement for each file found
# awk '{print "@import \"" $1"\";"}'
# remove any distracting leading underscores from the filenames
# sed 's#/_#/#'
find app/assets/stylesheets/*/* -name '*.scss' | cut -c 24- | awk '{print "@import \"" $1"\";"}' | sed 's#/_#/#'
# copy the output to the clipboard (osx)
if command -v pbcopy > /dev/null; then
find app/assets/stylesheets/*/* -name '*.scss' | cut -c 24- | awk '{print "@import \"" $1"\";"}' | sed 's#/_#/#' | pbcopy
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment