Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Gulpでscss, coffee, imagemin, livereload
gulp = require 'gulp'
imagemin = require 'gulp-imagemin'
plumber = require 'gulp-plumber'
coffee = require 'gulp-coffee'
concat = require 'gulp-concat'
uglify = require 'gulp-uglify'
sass = require 'gulp-sass'
webserver = require 'gulp-webserver'
gulp.task 'img', ->
gulp.src ['./src/image/*.jpg', './src/image/*.png']
.pipe imagemin()
.pipe gulp.dest './dist/image'
gulp.task 'js', ->
gulp.src './src/coffee/*.coffee'
.pipe plumber()
.pipe coffee()
.pipe concat 'all.min.js'
.pipe uglify()
.pipe gulp.dest './dist/js'
gulp.task 'css', ->
gulp.src './src/scss/*.scss'
.pipe plumber()
.pipe sass()
.pipe gulp.dest './dist/css'
gulp.task 'watch', -> './src/coffee/*.coffee', ['js'] './src/scss/*.scss', ['css'] './dist/*.html', ['watch']
gulp.task 'webserver', ->
gulp.src './dist'
.pipe webserver {
host: 'localhost'
livereload: true
gulp.task 'default', ['img', 'js', 'css', 'watch', 'webserver']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment