-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.coffee
58 lines (47 loc) · 1.31 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
gulp = require "gulp"
coffee = require "gulp-coffee"
gulpif = require "gulp-if"
util = require "gulp-util"
sourcemaps = require "gulp-sourcemaps"
stripDebug = require "gulp-strip-debug"
browserSync = require "browser-sync"
eslint = require "gulp-eslint"
mainFileName = "ubu.detect"
mainFilePath = "./src/#{mainFileName}.coffee"
distDir = "./dist"
isDev = true
isProduction = false
if util.env.production
isDev = false
isProduction = true
gulp.task "coffee", ->
gulp.src mainFilePath
.pipe gulpif isDev, sourcemaps.init()
.pipe coffee {bare: false}
.pipe gulpif isDev, sourcemaps.write()
.pipe gulpif isProduction, stripDebug()
.pipe gulp.dest distDir
gulp.task "lint", ->
gulp.src "#{distDir}/#{mainFileName}.js"
.pipe eslint {useEslintrc: true}
.pipe eslint.format()
.pipe eslint.failOnError()
gulp.task "bs", ->
browserSync
server:
baseDir: "./"
startPath: "./example"
port: 8000
open: true
notify: false
gulp.task "bs-reload", ->
browserSync.reload()
defaultTasks = ["coffee"]
if isDev
defaultTasks.push "bs"
if isProduction
defaultTasks.push "lint"
gulp.task "default", defaultTasks, ->
if isDev
gulp.watch mainFilePath, ["coffee", "bs-reload"]
gulp.watch "./example/index.html", ["bs-reload"]