-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
94 lines (81 loc) · 2.61 KB
/
gulpfile.js
File metadata and controls
94 lines (81 loc) · 2.61 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
* Gulp plugin setup
* =================
*/
var gulp = require('gulp');
// Watches single files
var watch = require('gulp-watch');
var gulpShopify = require('gulp-shopify-upload');
// Grabs your API credentials
var config = require('./config.json');
// Compiles SCSS files
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
// Notifies of errors
var notify = require("gulp-notify");
// Includes the Bourbon Neat libraries
var neat = require('node-neat').includePaths;
// Concats your JS files
var browserify = require('browserify');
var watchify = require('watchify');
var source = require('vinyl-source-stream');
var imagemin = require('gulp-imagemin');
var changed = require('gulp-changed');
function handleErrors() {
var args = Array.prototype.slice.call(arguments);
// Send error to notification center with gulp-notify
notify.onError({
title: "Compile Error",
message: "<%= error %>"
}).apply(this, args);
// Keep gulp from hanging on this task
this.emit('end');
}
gulp.task('shopifywatch', function() {
var options = {
"basePath": "./Timber/"
};
return watch('./Timber/+(assets|layout|config|snippets|templates|locales)/**')
.pipe(gulpShopify(config.shopify_api_key, config.shopify_password, config.shopify_url, null, options));
});
gulp.task('sass', function () {
gulp.src('./lib/scss/*.{sass,scss}')
.pipe(sass({includePaths: neat}))
.on('error', handleErrors)
.pipe(autoprefixer({ browsers: ['last 2 version'] }))
.pipe(gulp.dest('./Timber/assets'));
});
gulp.task('browserify', function() {
return browserify('./lib/js/app.js')
.bundle()
.on('error', handleErrors)
//Pass desired output filename to vinyl-source-stream
.pipe(source('bundle.js'))
// Start piping stream to tasks!
.pipe(gulp.dest('./Timber/assets/'));
});
gulp.task('images', function() {
return gulp.src('./lib/images/**')
.pipe(changed('./Timber/assets/')) // Ignore unchanged files
.pipe(imagemin()) // Optimize
.pipe(gulp.dest('./Timber/assets/'))
});
gulp.task('watch', function () {
gulp.watch('./lib/scss/**/*.{sass,scss}', ['sass']);
gulp.watch('./lib/js/**/*.js', ['browserify']);
var watcher = watchify(browserify({
// Specify the entry point of your app
entries: ['./lib/js/app.js'],
debug: true,
cache: {}, packageCache: {}, fullPaths: true
}));
return watcher.on('update', function() {
watcher.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest('./Timber/assets/'))
})
});
// Default gulp action when gulp is run
gulp.task('default', [
'shopifywatch', 'watch'
]);