-
Notifications
You must be signed in to change notification settings - Fork 109
/
Gruntfile.js
150 lines (144 loc) · 3.9 KB
/
Gruntfile.js
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
139
140
141
142
143
144
145
146
147
148
149
150
var fs = require('fs');
module.exports = function(grunt) {
var pathToInk = 'node_modules/grunt-jsdoc/node_modules/ink-docstrap';
var tripLicenseInfo = fs.readFileSync('./src/trip._header_.js', 'utf8');
// Project configuration.
grunt.initConfig({
qunit: {
all: {
options: {
timeout: 10000,
urls: [
'http://localhost:8000/tests/core/test.html',
'http://localhost:8000/tests/trip_events/test.html',
'http://localhost:8000/tests/directions/test.html',
'http://localhost:8000/tests/themes/test.html',
'http://localhost:8000/tests/key_events/test.html',
'http://localhost:8000/tests/integration/test.html',
]
}
}
},
connect: {
server: {
option: {
port: 8000,
base: 'tests'
}
}
},
sass: {
dist_non_compressed: {
options: {
compass: true,
sourcemap: 'none'
},
files: {
'dist/trip.css': './src/styles/trip.all.scss',
'dist/trip.nodep.css': './src/styles/trip.nodep.scss'
}
},
dist_compressed: {
options: {
compass: true,
style: 'compressed',
sourcemap: 'none'
},
files: {
'dist/trip.min.css': './src/styles/trip.all.scss',
'dist/trip.nodep.min.css': './src/styles/trip.nodep.scss'
}
}
},
webpack: {
'trip.js': require('./webpack.config.js')
},
uglify: {
options: {
mangle: false,
banner: tripLicenseInfo
},
target: {
files: {
'./dist/trip.min.js': ['./dist/trip.js']
}
}
},
jscs: {
// we will check distributed version directly and if there is any wrong,
// we can go find related line from sources.
src: 'src/trip.*.js',
options: {
config: '.jscsrc',
verbose: true
}
},
jshint: {
options: {
maxlen: 80
},
all: [
'Gruntfile.js',
'src/trip.*.js'
],
},
replace: {
configfiles: {
src: [
'package.json',
'bower.json'
],
overwrite: true,
replacements: [{
from: (function() {
return new RegExp('"version": "' + grunt.option('oldv') + '",');
})(),
to: function() {
return '"version": "' + grunt.option('newv') + '",';
}
}]
},
sourcefiles: {
src: [
'src/trip._header_.js',
'README.md'
],
overwrite: true,
replacements: [{
from: (function() {
return new RegExp(grunt.option('oldv'), 'g');
})(),
to: function() {
return grunt.option('newv');
}
}]
}
}
});
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-webpack');
grunt.loadNpmTasks('grunt-text-replace');
grunt.loadNpmTasks('grunt-jscs');
grunt.loadNpmTasks('grunt-contrib-uglify');
// Default task(s).
grunt.registerTask('test', ['connect', 'qunit']);
grunt.registerTask('build-js', ['jshint', 'jscs', 'webpack', 'uglify']);
grunt.registerTask('build-css', ['sass']);
grunt.registerTask('build', ['build-js', 'build-css']);
grunt.registerTask('bumpversion',
['replace:configfiles', 'replace:sourcefiles']);
// How to bump version ?
//
// grunt bumpversion --oldv=1.3.0 --newv=2.0.0 && grunt build
//
// NOTE:
//
// 1. After bumping versions, we will also build again to make sure
// this change get reflected into built files also.
//
// 2. Because the matching rule is very easy, we have to check version
// again after bumping to make sure we won't override the wrong words.
};