-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGulpfile.coffee
99 lines (84 loc) · 2.44 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
_ = require 'lodash'
del = require 'del'
gulp = require 'gulp'
karma = require('karma').server
rename = require 'gulp-rename'
webpack = require 'gulp-webpack'
coffeelint = require 'gulp-coffeelint'
RewirePlugin = require 'rewire-webpack'
webpackSource = require 'webpack'
karmaConf = require './karma.defaults'
packangeConf = require './package.json'
paths =
coffee: ['./src/**/*.coffee', './*.coffee', './test/**/*.coffee']
rootScripts: './src/index.coffee'
rootTests: './test/**/*.coffee'
dist: './dist/'
build: './build/'
webpackDistConfig =
module:
postLoaders: [
{test: /\.coffee$/, loader: 'transform/cacheable?envify'}
]
loaders: [
{test: /\.coffee$/, loader: 'coffee'}
{test: /\.json$/, loader: 'json'}
]
resolve:
extensions: ['.coffee', '.js', '.json', '']
gulp.task 'build', ['clean:dist', 'scripts:dist']
gulp.task 'test', ['scripts:test', 'lint'], (cb) ->
karma.start _.defaults(singleRun: true, karmaConf), cb
gulp.task 'watch', ->
gulp.watch paths.coffee, ['test:phantom']
gulp.task 'lint', ->
gulp.src paths.coffee
.pipe coffeelint()
.pipe coffeelint.reporter()
gulp.task 'scripts:test', ->
gulp.src paths.rootTests
.pipe webpack
devtool: '#inline-source-map'
module:
postLoaders: [
{test: /\.coffee$/, loader: 'transform/cacheable?envify'}
]
loaders: [
{test: /\.coffee$/, loader: 'coffee'}
{test: /\.json$/, loader: 'json'}
]
plugins: [
new RewirePlugin()
]
resolve:
extensions: ['.coffee', '.js', '.json', '']
.pipe rename 'tests.js'
.pipe gulp.dest paths.build
gulp.task 'test:phantom', ['scripts:test'], (cb) ->
karma.start _.defaults({
singleRun: true,
browsers: ['PhantomJS']
}, karmaConf), cb
gulp.task 'clean:dist', (cb) ->
del paths.dist, cb
gulp.task 'scripts:dist', ['scripts:dist:npm', 'scripts:dist:web']
gulp.task 'scripts:dist:npm', ['clean:dist'], ->
gulp.src paths.rootScripts
.pipe webpack _.defaults
output:
library: 'PortalGun'
libraryTarget: 'commonjs2'
, webpackDistConfig
.pipe rename "#{packangeConf.name}.js"
.pipe gulp.dest paths.dist
gulp.task 'scripts:dist:web', ['clean:dist'], ->
gulp.src paths.rootScripts
.pipe webpack _.defaults
output:
library: 'PortalGun'
plugins: [
new webpackSource.optimize.UglifyJsPlugin()
]
, webpackDistConfig
.pipe rename "#{packangeConf.name}.min.js"
.pipe gulp.dest paths.dist