Created
May 10, 2014 07:47
-
-
Save cognitom/48a8f39e44fb9758825a to your computer and use it in GitHub Desktop.
gulpfile example to integrate with Rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gulp = require 'gulp' | |
π = plugins = (require 'gulp-load-plugins')() | |
# Directories | |
CSSDIR = './app/assets/stylesheets' | |
JSDIR = './app/assets/javascripts' | |
FONTDIR = './app/assets/fonts' | |
# CSS | |
gulp.task 'css', -> | |
gulp.src ["#{CSSDIR}/v1/src/standard.css"] | |
.pipe π.cssimport() | |
.pipe gulp.dest "#{CSSDIR}/v1/" | |
gulp.src ["#{CSSDIR}/v1/src/images.css"] | |
.pipe π.base64 maxImageSize: 32768 # dataURI | |
.pipe π.replace 'url(../../../images/', 'image-url(' | |
.pipe π.rename extname: '.css.scss' | |
.pipe gulp.dest "#{CSSDIR}/v1/" | |
# Fonts | |
gulp.task 'font', -> | |
gulp.src ["#{FONTDIR}/v1/src/Symbols.sketch"] | |
.pipe π.sketch | |
export: 'artboards' | |
formats: 'svg' | |
.pipe π.iconfont | |
fontName: 'symbols' | |
fontHeight: 560 | |
descent: 0 | |
.on 'codepoints', (codepoints) -> | |
gulp.src "#{FONTDIR}/v1/src/symbols.css" | |
.pipe π.consolidate 'lodash', glyphs: codepoints | |
.pipe gulp.dest "#{FONTDIR}/v1/" # for preview | |
.pipe π.replace /url\('(.+?)'\)/g, 'url(\'<%= asset_path "v1/$1" %>\')' | |
.pipe π.rename extname: '.css.erb' | |
.pipe gulp.dest "#{CSSDIR}/v1/" # Rails | |
.pipe gulp.dest "#{FONTDIR}/v1/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment