-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.ls
115 lines (98 loc) · 3.28 KB
/
gulpfile.ls
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
require! {
gulp
webpack
child_process
nib
connect
path
fs
'strip-json-comments'
'gulp-util'
'gulp-jade'
'gulp-stylus'
'gulp-livereload'
'serve-static'
Promise: bluebird
'./src/livescript/components/Constants.ls'
}
const EXTENSION_ID = \eeabdaneafdojlhagbcpiiplpmabhnhl
gulp.task \default, <[watch]>
# Compile both the content script and background script.
# Since we have multiple entry points here, we can use webpack directly without
# bothering using gulp-webpack.
#
webpack-cache = {}
gulp.task \pack, <[build]>, ->
manifest = JSON.parse strip-json-comments fs.read-file-sync './build/manifest.json', 'utf-8'
version = manifest.version
build-dir = path.resolve './build/'
pem = path.resolve 'build.pem'
child_process.exec-sync "
\"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome
\" --pack-extension=#{build-dir} --pack-extension-key=#{pem}
"
child_process.exec-sync "mv build.crx dist/#{version}.crx"
gulp.task \webpack, (cb)->
webpack do
entry:
content-script: './src/livescript/contentScript.ls'
background: './src/livescript/background.ls'
page-diff-data-mock: './src/livescript/pageDiffDataMock.ls'
report: './src/javascript/report.js'
renderer-script: './src/livescript/rendererScript.ls'
injected-renderer-script: './src/livescript/injectedRendererScript.ls'
seess-mock: './src/javascript/seessMock.js'
output:
path: './build'
filename: "[name].js",
module:
loaders:
* test: /\.ls$/
loader: 'livescript'
* test: /\.coffee$/
loader: 'coffee-loader'
* test: /src\/javascript\/.+\.js$/
loaders: <[jshint jsx-loader]>
resolve:
alias:
'protocol': './protocol.coffee' # For interconnected components in Livereload
cache: webpack-cache
(err, stats) ->
throw new gulp-util.PluginError \webpack, err if err
# http://webpack.github.io/docs/node.js-api.html
gulp-util.log '[webpack]', stats.toString!
cb!
gulp.task \jade, ->
gulp.src './src/jade/*.jade'
.pipe gulp-jade pretty: true
.pipe gulp.dest './build/'
gulp.task \stylus, ->
gulp.src './src/stylus/*.styl'
.pipe gulp-stylus use: [nib!]
.pipe gulp.dest './build/assets/'
gulp.task \reload, ->
(resolve, reject) <-! new Promise _
resp = (err) ->
if err
reject!
else
resolve!
child_process.exec "curl http://localhost:24601/r?ext=#{Constants.EXTENSION_ID}", resp
..stdout.pipe process.stdout
..stderr.pipe process.stderr
gulp.task \build, <[webpack jade stylus]>
gulp.task \watch, <[build]> ->
gulp.watch './src/livescript/**/*', <[webpack reload]>
gulp.watch './src/javascript/**/*' <[webpack]>
gulp.watch './src/jade/*.jade', <[jade]>
gulp.watch './src/stylus/*.styl', <[stylus]>
# Static http server & livereload server for developing report pages
server = connect!
port = process.env.PORT || 5000
server.use serve-static('build') .listen port
console.log "Open http://localhost:#{port}/report.html to develop report page"
livereload-server = gulp-livereload!
livereload-server.changed!
gulp.watch <[build/assets/*.css build/*.html build/report.js build/chromeMock.js]> .on \change, ->
console.log "Change detected: #{it.path}"
livereload-server.changed it.path