Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize npm dependencies and gulpfiles. #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 27 additions & 20 deletions Gulpfile.coffee
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
gulp = require 'gulp'
FwdRef = require 'undertaker-forward-reference'
es = require 'event-stream'
sass = require 'gulp-sass'
concat = require 'gulp-concat'
minifyCss = require 'gulp-minify-css'
cleanCSS = require 'gulp-clean-css'
rename = require 'gulp-rename'
autoprefixer = require 'gulp-autoprefixer'
postcss = require 'gulp-postcss'
mqpacker = require 'css-mqpacker'
browserSync = require 'browser-sync'
argv = require('yargs').argv

gulp.registry(FwdRef())

themesDir = 'themes'
workingDir = 'themes/base'

Expand All @@ -29,40 +32,44 @@ getDistDir = (output)->
dir += "/#{output}"
return dir

gulp.task 'sass', ->
gulp.src sources.sass
sassTask = () ->
return gulp.src sources.sass
.pipe(sass().on('error', sass.logError))
.pipe autoprefixer(cascade: false, browsers: ['> 0.25%'])
.pipe gulp.dest(workingDir)

gulp.task 'min', ['sass'], ->
gulp.src sources.compiled
minTask = () ->
return gulp.src sources.compiled
.pipe(postcss([mqpacker]))
.pipe(minifyCss())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest(workingDir))

gulp.src(sources.compiled)
.pipe(minifyCss())
.pipe(cleanCSS())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest(workingDir))

gulp.task 'watch', ->
gulp.watch [watch.sass], ['sass']
watchTask = gulp.series (done) ->
gulp.watch([watch.sass]).on 'change', sassTask
done()

gulp.task 'sync', ['dev'], ->
syncTask = gulp.series (done) ->
proxy = argv.proxy ? 'snipcart.client/'
sync = browserSync.create proxy
sync.init
port: 3006
proxy: proxy
serveStatic: ['.']
ui:
port: 3007
port: 3007
gulp.watch(sources.compiled).on 'change', sync.reload
done()

deployTask = () ->
return gulp.src(["#{themesDir}/**/*", '!**/*.scss', '!**/sass', '!**/styles.css'])
.pipe(gulp.dest(getDistDir()))

gulp.task 'sass', gulp.series(sassTask)
gulp.task 'min', gulp.series('sass', minTask)
gulp.task 'watch', gulp.series(watchTask)
gulp.task 'dev', gulp.series('default', 'watch')
gulp.task 'sync', gulp.series('dev', syncTask)
gulp.task 'deploy', gulp.series('min', deployTask)

gulp.task 'dev', ['default', 'watch']
gulp.task 'default', ['sass']
gulp.task 'deploy', ['min'], ->
gulp.src(["#{themesDir}/**/*", '!**/*.scss', '!**/sass', '!**/styles.css'])
.pipe(gulp.dest(getDistDir()))
gulp.task 'default', gulp.series('sass')
Loading