Skip to content

Instantly share code, notes, and snippets.

@hideki-a
Last active August 29, 2015 14:04
Show Gist options
  • Save hideki-a/98ae6d2b813ff33f82de to your computer and use it in GitHub Desktop.
Save hideki-a/98ae6d2b813ff33f82de to your computer and use it in GitHub Desktop.
# Path Settings
basepath = '../htdocs/'
paths =
styles:
src: basepath + '_scss/'
dest: basepath + 'css/'
images:
src: basepath + '**/*.{png,jpg,svg}'
# Read Modules
gulp = require 'gulp'
path = require 'path'
plugins = require('gulp-load-plugins')()
# Function
# isAddedChanged = (file) ->
# return file.event == 'added' || file.event == 'changed'
# Tasks
gulp.task 'webserver', ->
gulp.src basepath
.pipe plugins.webserver
livereload: true
host: '0.0.0.0'
port: 3501
gulp.task 'styles', ->
gulp.src paths.styles.src + 'basic.scss'
.pipe plugins.rubySass
style: 'expanded'
sourcemap: true
precision: 3
loadPath: path.join(__dirname) + '/' + paths.styles.src
.pipe plugins.autoprefixer 'last 2 version', 'ie 9', 'ie 8', 'Firefox ESR'
.pipe gulp.dest paths.styles.dest
# gulp.task 'imagemin:all', ->
gulp.task 'imagemin', ->
gulp.src paths.images.src
.pipe plugins.imagemin
progressive: true
svgoPlugins: [
removeViewBox: false
]
.pipe gulp.dest basepath # Overwrite files.
# gulp.task 'imagemin:changed', ->
# plugins.watch
# glob: paths.images.src
# , (files) ->
# files.pipe plugins.filter(isAddedChanged)
# .pipe plugins.imagemin
# progressive: true
# svgoPlugins: [
# removeViewBox: false
# ]
# .pipe gulp.dest basepath # Overwrite files.
# return
gulp.task 'watch', ->
gulp.watch paths.styles.src + '*.scss', ['styles']
return
gulp.task 'default', [
'webserver'
'styles'
'watch'
# 'imagemin:changed'
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment