-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgulpfile.coffee
67 lines (58 loc) · 1.73 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
gulp = require "gulp"
zip = require "gulp-zip"
less = require "gulp-less"
streamify = require "gulp-streamify"
uglify = require "gulp-uglify"
minify = require "gulp-minify-css"
browserify = require "browserify"
source = require "vinyl-source-stream"
del = require "del"
forceDeploy = require "gulp-jsforce-deploy"
# Building CSS files from LESS source
gulp.task "css", ->
gulp.src "./src/styles/main.less"
.pipe less()
.pipe minify()
.pipe gulp.dest "./build/css"
# Compile and bundle JS file from CoffeeScript source code
gulp.task "js", ->
browserify
entries: [ "./src/scripts/main.coffee" ]
extensions: [ ".coffee" ]
.bundle()
.pipe source "main.js"
.pipe streamify uglify()
.pipe gulp.dest "./build/js"
# Copy all static files in src directory to temporary build directory
gulp.task "statics", ->
gulp.src [ "./src/**/*.html", "./src/images/**/*" ], base: "./src"
.pipe gulp.dest "./build"
# Zip all built files as a static resource file
gulp.task "zip", [ "css", "js", "statics" ], ->
gulp.src "./build/**/*"
.pipe zip("MyApp.resource")
.pipe gulp.dest "./pkg/staticresources"
# Build
gulp.task "build", [ "zip" ]
# Cleanup built files
gulp.task "clean", ->
del [ "./build" ]
###
# Deploying package to Salesforce
###
gulp.task "deploy", ->
gulp.src "./pkg/**/*", base: "."
.pipe zip("pkg.zip")
.pipe forceDeploy
username: process.env.SF_USERNAME
password: process.env.SF_PASSWORD
# loginUrl: "https://test.salesforce.com"
# pollTimeout: 120*1000
# pollInterval: 10*1000
# version: '33.0'
#
gulp.task "watch", ->
gulp.watch "./src/**/*", [ "build" ]
gulp.watch "./pkg/**/*", [ "deploy" ]
# Default entry point
gulp.task "default", [ "build", "deploy" ]