-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgruntfile.coffee
138 lines (121 loc) · 3.93 KB
/
gruntfile.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
137
138
module.exports = (grunt) ->
group = (args...) -> Array::concat.call(args...)
# Project configuration.
grunt.initConfig
pkg: grunt.file.readJSON('package.json')
ts:
options:
fast: 'never'
verbose: true
compiler: './node_modules/typescript/bin/tsc'
# additionalFlags: '--traceResolution'
build:
tsconfig:
tsconfig: './tsconfig_build.json'
passThrough: true
specs:
tsconfig:
tsconfig: './tsconfig_specs.json'
passThrough: true
specHelpers:
tsconfig:
tsconfig: './tsconfig_specHelpers.json'
passThrough: true
coffee:
options: { bare: true }
build:
files: [{
expand: true
cwd: 'src'
src: ['**/*.coffee']
dest: 'tmp/bin-es6/'
ext: '.js'
}]
test:
files: [
{expand: true, cwd: 'specs', src: ['**/*.coffee'], dest: 'tmp/specs-es6/', ext: '.js'}
{expand: true, cwd: 'specHelpers', src: ['**/*.coffee'], dest: 'tmp/specHelpers/', ext: '.js'}
]
copy:
build:
src: 'src/**/*.js'
dest: 'tmp/bin-es6/'
test:
files: [
{expand: true, src: ['specs/**/*.js'], dest: 'tmp/specs-es6/'}
{expand: true, src: ['specHelpers/**/*.js'], dest: 'tmp/specHelpers/'}
]
babel:
options:
presets: ['babel-preset-es2015']
plugins: ['babel-plugin-transform-es2015-modules-amd', 'external-helpers']
build:
files: [{
expand: true
cwd: 'tmp/bin-es6'
src: ['**/*.js']
dest: 'bin/'
ext: '.js'
}]
test:
files: [{
expand: true
cwd: 'tmp/specs-es6'
src: ['**/*.js']
dest: 'tmp/specs/'
ext: '.js'
}]
jasmine:
test:
options:
specs: ['tmp/specs/**/*.js']
vendor: ['lib/babel-helpers.js']
helpers: ['tmp/specHelpers/**/*.js']
template: require('grunt-template-jasmine-requirejs')
templateOptions:
requireConfig:
baseUrl: 'bin/'
deps: ['../node_modules/babel-polyfill/dist/polyfill']
requirejs:
dist:
options:
almond: true
baseUrl: 'bin/'
paths:
'almond': '../node_modules/almond/almond'
# replaceRequireScript: [module: 'platter/main', modulePath: 'platter/main']
include: ['../lib/babel-helpers', 'platter/main', '../node_modules/babel-polyfill/dist/polyfill']
optimize: 'none'
wrap:
startFile: 'frags/start.js'
endFile: 'frags/end.js'
name: 'almond'
out: 'tmp/<%= pkg.name %>.js'
uglify:
options:
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
dist:
src: 'tmp/<%= pkg.name %>.js'
dest: 'dist/<%= pkg.name %>.min.js'
clean:
build: ['bin']
post: ['tmp']
grunt.loadNpmTasks('grunt-ts')
grunt.loadNpmTasks('grunt-contrib-clean')
grunt.loadNpmTasks('grunt-contrib-coffee')
grunt.loadNpmTasks('grunt-contrib-copy')
grunt.loadNpmTasks('grunt-babel')
grunt.loadNpmTasks('grunt-contrib-jasmine')
grunt.loadNpmTasks('grunt-contrib-requirejs')
grunt.loadNpmTasks('grunt-contrib-uglify')
buildTasks = [
'ts:build', 'coffee:build', 'copy:build', 'clean:build', 'babel:build'
]
testTasks = ['ts:specs', 'ts:specHelpers', 'coffee:test', 'copy:test',
'babel:test', 'jasmine:test'
]
distTasks = ['requirejs:dist', 'uglify:dist']
cleanTasks = ['clean:post']
grunt.registerTask('build', group(cleanTasks, buildTasks, cleanTasks))
grunt.registerTask('test', group(cleanTasks, buildTasks, testTasks, cleanTasks))
grunt.registerTask('dist', group(cleanTasks, buildTasks, testTasks, distTasks, cleanTasks))