forked from snipcart/snipcart-theme-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.coffee
68 lines (58 loc) · 1.82 KB
/
Gulpfile.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
gulp = require 'gulp'
es = require 'event-stream'
sass = require 'gulp-sass'
concat = require 'gulp-concat'
minifyCss = require 'gulp-minify-css'
rename = require 'gulp-rename'
autoprefixer = require 'gulp-autoprefixer'
postcss = require 'gulp-postcss'
mqpacker = require 'css-mqpacker'
browserSync = require 'browser-sync'
argv = require('yargs').option('snipcartVersion', {type: 'string'}).argv
themesDir = 'themes'
workingDir = 'themes/base'
sources =
sass: "#{workingDir}/sass/snipcart.scss"
compiled: "#{workingDir}/snipcart.css"
watch =
sass: "#{workingDir}/sass/**/*.scss"
getDistDir = (output)->
version = "2.0"
dir = './dist/themes'
if argv.snipcartVersion
dir = "./dist/themes/#{argv.snipcartVersion}"
if output
dir += "/#{output}"
return dir
gulp.task 'sass', ->
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
.pipe(postcss([mqpacker]))
.pipe(minifyCss())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest(workingDir))
gulp.src(sources.compiled)
.pipe(minifyCss())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest(workingDir))
gulp.task 'watch', ->
gulp.watch [watch.sass], ['sass']
gulp.task 'sync', ['dev'], ->
proxy = argv.proxy ? 'snipcart.client/'
sync = browserSync.create proxy
sync.init
port: 3006
proxy: proxy
serveStatic: ['.']
ui:
port: 3007
gulp.watch(sources.compiled).on 'change', sync.reload
gulp.task 'dev', ['default', 'watch']
gulp.task 'default', ['sass']
gulp.task 'deploy', ['min'], ->
gulp.src(["#{themesDir}/**/*", '!**/*.scss', '!**/sass', '!**/styles.css'])
.pipe(gulp.dest(getDistDir()))