Skip to content

Instantly share code, notes, and snippets.

@abarcenas29
Created February 25, 2016 16:37
Show Gist options
  • Save abarcenas29/88bcd0dd00d3aa941924 to your computer and use it in GitHub Desktop.
Save abarcenas29/88bcd0dd00d3aa941924 to your computer and use it in GitHub Desktop.
gulpfile code for ghost theme
gulp = require "gulp"
_ = require 'underscore'
mainBowerFiles = require 'gulp-main-bower-files'
rename = require 'gulp-rename'
del = require 'del'
fse = require 'fs-extra'
path = require 'path'
plumber = require 'gulp-plumber'
coffee = require "gulp-coffee"
uglify = require "gulp-uglify"
concat = require "gulp-concat"
sourcemap = require "gulp-sourcemaps"
ngAnnotate= require "gulp-ng-annotate"
sass = require "gulp-ruby-sass"
prefixer = require "gulp-autoprefixer"
minfiyCss = require "gulp-minify-css"
jade = require "gulp-jade"
currentPath = path.parse __dirname
root = currentPath.root
targetPath = path.join root,"www","megane.local","content","themes","megane"
gulp.task "sass", ->
targetPath = path.join targetPath,"assets","css"
sourcePath = "styles/template/**/*.sass"
sass(sourcePath,{sourcemap:true})
.pipe(plumber())
.on('error',sass.logError)
.pipe(prefixer())
.pipe(minfiyCss())
.pipe(gulp.dest(targetPath))
gulp.task "jade", ->
sourcePath = "jade/template/**/*.jade"
gulp.src(sourcePath)
.pipe(plumber())
.pipe(jade {pretty:true})
.pipe(rename (path) ->
path.extname = ".hbs"
return path
)
.pipe(gulp.dest(targetPath))
gulp.task "angular", ->
sourcePath = [
"angular/config/*.coffee"
"angular/services/**/*.coffee"
"angular/directives/**/*.coffee"
"angular/controllers/**/*.coffee"
]
targetPath = path.join targetPath,"assets","js"
gulp.src(sourcePath)
.pipe(plumber())
.pipe(coffee {bare:true})
.pipe(ngAnnotate {single_quotes:true})
.pipe(sourcemap.init {loadMaps: true})
.pipe(concat 'angular.min.js')
.pipe(uglify())
.pipe(sourcemap.write())
.pipe(gulp.dest targetPath)
gulp.task "default",['jade','angular','sass','watch']
gulp.task "watch", ->
gulp.watch ["./jade/**/*.jade"], ['jade']
gulp.watch ["./sass/**/*.sass"], ['sass']
gulp.watch ["./angular/**/*.coffee"], ['angular']
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment