forked from CiderSqueezy/bt-desktop
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.coffee
executable file
·136 lines (114 loc) · 4.02 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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
gulp = require 'gulp'
gutil = require 'gulp-util'
webpack = require("webpack")
WebpackDevServer = require("webpack-dev-server")
webpackConfig = require("./webpack.config.js")
webpackProductionConfig = require("./webpack.production.config.js")
map = require 'map-stream'
touch = require 'touch'
_ = require 'underscore'
# Load plugins
$ = require('gulp-load-plugins')()
# CSS
gulp.task('css', ->
gulp.src(['src/styles/*.sass', 'src/styles/*.scss'])
.pipe($.sourcemaps.init())
.pipe($.sass())
.pipe($.sourcemaps.write())
.on('error', (err) ->
gutil.log err
)
.pipe($.size())
.pipe(gulp.dest('public/'))
.pipe(map((a, cb) ->
if devServer.invalidate? then devServer.invalidate()
cb()
))
)
gulp.task('copy-assets', ->
gulp.src(['assets/**', 'src/scripts/native.js', 'main.js', 'package.json'])
.pipe(gulp.dest('public'))
.pipe($.size())
)
# Some quick notes on using fontcustom.
# First you need to install some additional software
# as detailed at https://github.com/FontCustom/fontcustom#installation
# On MacOSX, this comment was the only way I got things to work: https://github.com/FontCustom/fontcustom/issues/209#issuecomment-48014939
# Otherwise I got a Python import error.
#
# Then once things are working, things here are setup so that the generated font
# is base64 encoded and included in the css file. For this to work, you
# need to edit the generated scss file at src/styles/_fontcustom.scss to remove
# its font-face imports.
# Font compilation
# gulp.task('font', $.shell.task([
# 'fontcustom compile'
# ]))
# gulp.task('font-base-64', ->
# gulp.src('assets/fonts/*.ttf')
# .pipe($.rename('fontcustom.ttf'))
# .pipe($.cssfont64())
# .pipe($.rename('_fontcustom_embedded.scss'))
# .pipe(gulp.dest('src/styles/'))
# )
gulp.task "webpack:build", (callback) ->
# Run webpack.
webpack webpackProductionConfig, (err, stats) ->
throw new gutil.PluginError("webpack:build", err) if err
gutil.log "[webpack:build]", stats.toString(colors: true)
callback()
return
# Create a single instance of the compiler to allow caching.
devCompiler = webpack(webpackConfig)
gulp.task "webpack:build-dev", (callback) ->
# Run webpack.
devCompiler.run (err, stats) ->
throw new gutil.PluginError("webpack:build-dev", err) if err
gutil.log "[webpack:build-dev]", stats.toString(colors: true)
callback()
return
return
devServer = {}
gulp.task "webpack-dev-server", (callback) ->
# Ensure there's a `./public/main.css` file that can be required.
touch.sync('./public/main.css', time: new Date(0))
# Start a webpack-dev-server.
devServer = new WebpackDevServer(webpack(webpackConfig),
contentBase: './public/'
hot: true
watchDelay: 100
noInfo: true
)
devServer.listen 8080, "0.0.0.0", (err) ->
throw new gutil.PluginError("webpack-dev-server", err) if err
gutil.log "[webpack-dev-server]", "http://localhost:8080"
callback()
return
gulp.task 'default', ->
gulp.start 'build'
gulp.task 'build', ['webpack:build', 'copy-assets']
gulp.task 'heroku:production', ['build']
gulp.task 'watch', ['copy-assets', 'webpack-dev-server'], ->
gulp.watch(['assets/**', 'src/scripts/native.js'], ['copy-assets'])
gulp.task 'package-native-mac', ["build"], ->
atomshell = require('gulp-atom-shell');
return gulp.src(['public/**', "package.json", "main.js"])
.pipe(atomshell({
platform: "darwin"
version: '0.34.3'
productName: 'BerryTube'
productVersion: '0.0.1'
darwinIcon: "bt.icns"
}))
.pipe(atomshell.zfsdest('dist/BerryTube.mac.zip'));
gulp.task 'package-native-win', ["build"], ->
atomshell = require('gulp-atom-shell');
return gulp.src(['public/**', "package.json", "main.js"])
.pipe(atomshell({
platform: "win32"
version: '0.34.3'
productName: 'BerryTube'
productVersion: '0.0.1'
winIcon: "bt.ico"
}))
.pipe(atomshell.zfsdest('dist/BerryTube.win.zip'));