forked from flowhub/the-graph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
126 lines (119 loc) · 3.05 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
(function() {
"use strict";
module.exports = function() {
var sources = {
scripts: ['Gruntfile.js', 'the-*/*.js', 'the-*/*.html', 'index.js'],
// elements: ['the-*/*.html'],
stylus: ['themes/*/*.styl'],
css: ['themes/*.css'],
tests: ['__tests__/*.js']
};
var externals = [
'react',
'react-dom',
'create-react-class',
'hammerjs',
'@pleasetrythisathome/react.animate'
];
var glob = require('glob');
var stylExpand = glob.sync('./themes/*.styl').join(' ');
this.initConfig({
pkg: this.file.readJSON('package.json'),
exec: {
jest: {
command: 'jest --verbose',
},
build_stylus: {
command: 'node ./node_modules/stylus/bin/stylus ' + stylExpand
},
build_fa: {
command: 'node ./scripts/build-font-awesome-javascript.js'
}
},
browserify: {
vendor: {
files: {
'dist/vendor.js': ['./vendor.js'],
},
options: {
require: externals
}
},
libs: {
files: {
'dist/the-graph.js': ['index.js'],
},
options: {
external: externals,
transform: ['coffeeify'],
browserifyOptions: {
standalone: 'TheGraph'
}
}
}
},
jshint: {
options: {
extract: 'auto',
strict: false,
newcap: false,
"globals": { "Polymer": true }
},
all: {
src: sources.scripts
},
force: {
src: sources.scripts,
options: { force: true }
}
},
connect: {
server: {
options: {
port: 3000,
hostname: '*', // Allow connection from mobile
livereload: true
}
}
},
watch: {
scripts: {
files: sources.scripts,
tasks: ['jshint:force', 'browserify:libs', 'exec:jest'],
options: {
livereload: true
}
},
stylus: {
files: sources.stylus,
tasks: ['exec:build_stylus'],
options: {
livereload: false
}
},
css: {
files: sources.css,
options: {
livereload: true
}
},
tests: {
files: sources.tests,
tasks: ['exec:jest'],
options: {
livereload: false
}
},
},
});
this.loadNpmTasks('grunt-exec');
this.loadNpmTasks('grunt-contrib-jshint');
this.loadNpmTasks('grunt-contrib-connect');
this.loadNpmTasks('grunt-contrib-watch');
this.loadNpmTasks('grunt-browserify');
this.registerTask('dev', ['connect', 'test', 'watch']);
this.registerTask('build', ['exec:build_stylus', 'exec:build_fa', 'browserify:libs', 'browserify:vendor']);
this.registerTask('test', ['jshint:all', 'build', 'exec:jest']);
this.registerTask('default', ['test']);
};
}).call(this);